访问本地文件仅适用于本地HTML文件 [英] Access to local files only work with local HTML file
问题描述
我想通过单击HTML链接来访问计算机上的本地文件
I would like to access a local file on my computer by clicking on a HTML link
<a href="file:///\\mynetworklink\users\myusername\public\mydoc.docx">Link to local file</a>
如果我从本地HTML文件进行操作,例如:
It works very well if I do it from a local HTML file for exemple from :
file:///D:/Profiles/myusername/Desktop/testfile.html
通过使用Javascript中的window.open,它甚至可以很好地工作:
It even work well by using window.open from Javascript :
<script type="text/javascript">
window.open('\\\\mynetworklink\\users\\myusername\\public\\mydoc.docx', 'MyWindow');
</script>
但是,如果我不允许使用Apache从我本地的PHP应用程序执行此操作,请执行以下操作.尝试使用链接标记时出现的错误示例:
But when I do it from my local PHP app with Apache if am not allowed to do so. Exemple of error while trying with a link tag :
不允许加载本地资源
Not allowed to load local resource
因此,我听说出于安全原因,Chrome/Firefox/IE以此方式阻止了本地文件访问.
So I heard that Chrome/Firefox/IE are blocking local file access this way for security reasons.
在不修改浏览器设置的情况下,有什么方法可以使它正常工作吗?许多客户都在使用这个应用程序,我不能要求所有人在其中修改设置.
Isn't there any way to make it work without modifying the browsers settings ? This app is used by a lot of customers and I can't ask everybody to modify there settings.
谢谢你,最好的问候.
推荐答案
因此,我听说出于安全原因,Chrome/Firefox/IE以此方式阻止了本地文件访问.
So I heard that Chrome/Firefox/IE are blocking local file access this way for security reasons.
是
在不修改浏览器设置的情况下,有什么方法可以使它正常工作吗?
Isn't there any way to make it work without modifying the browsers settings ?
不.这将使其成为毫无意义的安全功能.
No. That would make it a pointless security feature.
这篇关于访问本地文件仅适用于本地HTML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!