简体   繁体   English

在我的nodejs应用程序中上传照片时遇到路径问题

[英]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. 我将所有照片保存在名为public和portPics的文件夹中,因为它们是我正在放幻灯片的工作的屏幕截图。 However. 然而。 in my index.hbs (using express-handlebars) I have a the code right here below 在我的index.hbs(使用express-handlebars)中,我在下面有一个代码

<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. 我不知道为什么不拍照,它甚至说当我发布带有下载标签的pdf文件时找不到文件。

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. 如果您的Express服务器上连接了记录器,请检查要访问的路由的路径。 If you don't have a logger, try morgan 如果您没有记录器,请尝试摩根

As your image is not visible, express with show 404 for some path. 由于您的图像不可见,请使用show 404表示某些路径。 Compare that path with the other paths. 将该路径与其他路径进行比较。 This will show you where its going wrong. 这将告诉您问题出在哪里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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