简体   繁体   中英

Having a path issue uploading photos in my nodejs app

I saved all my photos inside a folder named public and portPics because they are screenshots of my work that I'm putting into a slideshow. However. in my index.hbs (using express-handlebars) I have a the code right here below

<img src="./../public/portPic/

however I tried debugging, doing ./ and then no dot. then right clicking and pasting the full path. I have no idea why its not taking the photos, It even says file cannot be found when I post a pdf file with the download tag.

Hopefully it's something small I went over too quick. This is for my portfolio please help!

As you haven't posted more code or screenshot of the file structure, I'm going to take a shot in dark.

../ will give you current directory. As you go on adding ../ , you will go to upper directories.

./ will give you application's root directory.

I don't think you can use ./ and ../ together

If you have a logger attached to the express server, check the path of routes that are getting accessed. If you don't have a logger, try morgan

As your image is not visible, express with show 404 for some path. Compare that path with the other paths. This will show you where its going wrong.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM