I save some images at location myproject/controllers/upload and in my app.js I mentioned app.use(express.static(__dirname + '/controllers/upload')); However when I am referring to the image in browser (direct hit) like -
http://localhost:3352/controllers/upload/profile_53ce49af9f5ae78d1db89876_img1.jpeg
I am unable to get any image, and throwing error -
Error: ENOENT, stat '/MYROOTDIR/prj/interface/generated/index.html'
Let me know what I am doing wrong here if any?
Ok..I solved the problem on my own.
Following is the thing that worked for me and now I am able to fetch images from the upload folder.
app.use('/controllers/upload', express.static(__dirname + "/controllers/upload"));
One More thing to add -
If you feel to hide your current folder structure you can rename it too like -
app.use('/public', express.static(__dirname + "/controllers/upload"));
Now the benefit is that you don't need to refer like this -
http://localhost:3352/controllers/upload/profile_53ce49af9f5ae78d1db89876_img1.jpeg
But -
http://localhost:3352/public/profile_53ce49af9f5ae78d1db89876_img1.jpeg