简体   繁体   English

如何链接到本地​​主机外部文件夹中的图像

[英]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. 我正在开发嵌入式网站,该网站将由运行Linux的设备提供服务。 We are trying to maintain a system where editable items are in root/var/data/.. and static files are in root/opt/.. 我们正在尝试维护一个系统,其中可编辑项目位于root / var / data / ..中,静态文件位于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 现在我的server.js位于root / opt / webapp / server.js,我在root / opt / webapp / html / file.html有一个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? 在file.html中我需要渲染root / var / data文件夹中的图像,但是我现在对这个工作的理解是节点认为localhost at root / opt / webapp(server.js的位置)我该如何标记到一个位于所述本地主机之外但仍在设备文件目录中的文件?

I attempted an absolute path but the html just assumed that it should start the chain from localhost so 我尝试了一个绝对路径,但html只是假设它应该从localhost启动链接

looks at http://localhost:8080/file:/C:/projects/root/var/data/fms/share/icons/avocado.png 查看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文件夹是.html文件中的两个文件夹,所以听起来你正在寻找:

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

It depends on how you're linking to the file, but you may also be able to use the absolute path relative to C: : 这取决于你如何链接到文件,但你也可以使用相对于C:的绝对路径:

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

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

相关问题 如何让我的链接文本不在Div之外运行? - How do i get my link text to not run outside of the Div? 如何href链接到我的文件所在文件夹之外的文件夹中的文件? - How to href link to a file that's in a folder outside of the folder my file is in? 当我的 HTML 文件在不同的文件夹中时,如何从另一个文件夹添加图像? - How do I add an image from another folder when my HTML file is in a different folder? 如何从链接下载图像? - how do i download an image from a link? 如何使用HTML中的相对链接将第二个文件夹与第一个文件夹链接? - How do I link my 2nd folder with my first folder using Relative Links in HTML? 如何将其他文件夹中的 JS 文件链接到页面? - How do I link JS file from other folder to a page? 如何防止图片链接成为整个页面的宽度? - How do i prevent my image link to be the width of the entire page? 当 multer 是 localhost 时,如何将文件从 multer 发送到托管在服务器上的网站文件夹 - How can i send a file from multer to my website folder which is hosted on a server while multer is localhost 如何链接文件夹中的文件? - how do I link files in a folder? 我如何自动换行以使我的手风琴图像消失在我的手风琴上 - How Do I Wrap Text So My Accordions Image Does Go OutSide My aAccordion
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM