简体   繁体   English

html 中的 src 不允许加载本地资源

[英]src in html not allowed to load a local resource

I am doing a project, where I need to show an image on html page.我正在做一个项目,我需要在 html 页面上显示图像。 The image is located in a.network drive.该图像位于网络驱动器中。 Using the below tag to refer to the image, I receive a "Not allowed to load local resource:" error.使用下面的标签引用图像,我收到“不允许加载本地资源:”错误。

<img src="file://sc19/dept0213/SSC_Data/SVD/SVD%20Robot%20Experiment/4b9262caa1b64079ad8b31c3a3662598_1/Measurement/bot_Images/4.png" alt="Image">

If I however, open a new tab in the same Edge web browser, and copy the file://sc19/dept0213/SSC_Data/SVD/SVD%20Robot%20Experiment/4b9262caa1b64079ad8b31c3a3662598_1/Measurement/bot_Images/4.png into the address bar, the image is displayed inside the web browser.但是,如果我在同一个 Edge web 浏览器中打开一个新选项卡,并将文件://sc19/dept0213/SSC_Data/SVD/SVD%20Robot%20Experiment/4b9262caa1b64079ad8b31c3a3662598_1/Measurement/bot_Images/4.png 复制到地址栏中,该图像显示在 web 浏览器中。 I have tried with Google Chrome in stead of Microsoft Edge and turned off the security feature, but still get the same error.我尝试使用 Google Chrome 代替 Microsoft Edge 并关闭了安全功能,但仍然出现相同的错误。

Additional information.附加信息。 The HTML page was rendered using Django as backend. HTML 页面是使用 Django 作为后端呈现的。 In my Django template I have.在我的 Django 模板中。

<img src="file://sc19/dept0213/SSC_Data/SVD/SVD%20Robot%20Experiment/4b9262caa1b64079ad8b31c3a3662598_1/Measurement/bot_Images/4.png" alt="Image">

Could an alternative approach be that the front end is doing a request to the backend that then fetches the image, and put it somewhere that can be reached from front end?另一种方法是前端向后端发出请求,然后获取图像,并将其放在前端可以到达的某个地方吗?

For my project, the solution I ended up using was for my frontend to send a request to the backend.对于我的项目,我最终使用的解决方案是让我的前端向后端发送请求。 The backend then fetches the image, and send it as a blob to the frontend.然后后端获取图像,并将其作为 blob 发送到前端。 I know that setting up a webserver is another possibility, but in this case my Django backend already acts as a webserver.我知道设置网络服务器是另一种可能性,但在这种情况下,我的 Django 后端已经充当网络服务器。

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

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