简体   繁体   中英

How do I link to an image from a folder outside of my localhost

I am working on embedded website that will be served by a device running Linux. We are trying to maintain a system where editable items are in root/var/data/.. and static files are in root/opt/..

Right now my server.js is located at root/opt/webapp/server.js, i have an html file at root/opt/webapp/html/file.html

in the file.html i need to render images that are in the root/var/data folder, but my understanding of now this works is node considers localhost at root/opt/webapp(the location of server.js) how do I tag to a file that is outside of said local host but still within the file directory of the device?

I attempted an absolute path but the html just assumed that it should start the chain from localhost so

looks at http://localhost:8080/file:/C:/projects/root/var/data/fms/share/icons/avocado.png

The var folder is two folders up from your .html file, so it sounds like you're looking for either:

  • ../../var/data/fms/share/icons/avocado.png (relative)
  • /root/var/data/fms/share/icons/avocado.png (root-relative)

It depends on how you're linking to the file, but you may also be able to use the absolute path relative to C: :

  • file:///C:/projects/root/var/data/fms/share/icons/avocado.png

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