I am working with on a user profile page with nodejs where the user can see his own avatar after login. The user has the posibility to upload the files to the uploads folder which is outside the regular htmlpath. I have the following folder structure:
- Layouts
- node_modules
- public (all static files)
- schema
uploads (user uploaded files)
eps euro-pool-1501781922012.jpgutil
- views
These are the settings for the htmlpath in app.js:
app.use(require('serve-static')(path.join(__dirname, 'public')));
app.use(require('method-override')());
app.use(express.static('public'));
on the client side i use this relative path to the image:
<img src="../uploads/eps/euro-pool-1501781922012.jpg" class="img-circle profile-avatar" alt="User avatar" data-pin-nopin="true">
i also tried
<img src="./uploads/eps/euro-pool-1501781922012.jpg" class="img-circle profile-avatar" alt="User avatar" data-pin-nopin="true">
but when i navigate to the page it failed to show the image and i get the folowing error back:
GET http://192.168.2.20:3000/uploads/eps/euro-pool-1501781922012.jpg 404 (Not Found)
I have two questions:
- Is it posible to acces files outside the htmlpath?
- How can i fix this problem without moving the whole folder to the public folder?
Many thanks,
Erik