This is my server's structure:

index.js
admin
|_ admin.html
public
|_ index.html
uploads
|_ some files...

and this is part of my server's code:

app.use(express.static(__dirname + '/public'))
app.use(express.static(__dirname + '/admin'))
app.use(express.static(__dirname + '/uploads'))

How can admin.html or index.html have access to the files from the uploads directory?
Because what I'm already doing doesn't seem to work. Specifically, images that originate from the uploads folder never show in either admin.html or index.html.

1 Answers

1
Community On Best Solutions

Assuming same folder structure with images folder in uploads and one image img.jpg

index.js
admin
|_ admin.html
public
|_ index.html
uploads
|_ images
  |_ img.jpg

As you are already serving public, uploads and admin folders as static, in html file can use

<img src="images/img.jpg" alt="" />