我可以在 Firefox 中打开本地文件,其链接如下: file:///home/user
可能的重复:
Firefox 链接到本地或网络页面不起作用
大家好,
我想知道如何为连接到我的网站(JAVA - JSP 页面)的用户提供通过 Web 浏览器显示其 PC 中文件内容的功能。
更准确地说,我想要一个按钮,当用户单击时,它会打开一个新选项卡或新窗口(浏览器的),其路径如下:file:///home/user...
我确实尝试过我的流程代码片段:
<script type="text/javascript">
[...]
window.open("file:///home/user...");
[...]
</script>
当我使用 Firefox 手动打开 html 文件时,这工作正常,但是当我尝试将其加载到应用程序服务器(Java EE)中时,它根本不起作用。我在我的错误控制台(firefox)中收到这样的消息:
Security Error: Content at http://localhost:8080/MyProject/test.jsp may not load
or link to file:///home/user.
这似乎是与 Firefox 安全策略相关的问题,但我仍然没有发现任何问题来解决我的问题...
您有什么想法吗这?
Possible Duplicate:
Firefox Links to local or network pages do not work
Hi all,
I would like to know how can i offer users that connected in my web site (in JAVA - JSP pages) to show the contents of files in THEIR PC over Web browser.
More precisely, i want to have a button, on what when user click, it open a new TAB or new window (of the browser) with path like : file:///home/user...
I did try with my flowing snippet of codes:
<script type="text/javascript">
[...]
window.open("file:///home/user...");
[...]
</script>
this works fine when i open my html file manually with Firefox, but when i try to load it in a application server (Java EE), it doesn't work at all. I get this kind of message in my error console (of firefox):
Security Error: Content at http://localhost:8080/MyProject/test.jsp may not load
or link to file:///home/user.
It seems to be a problem related to the security policies of Firefox, still i didn't found any issues to resolve my problem ...
Do you have any ideas about this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
由于安全原因这是不可能的。
It's impossible because of security reasons.
不允许远程页面链接到
file://
页面,因为它允许对浏览器进行攻击,在某些情况下还对操作系统进行攻击。例如,Linux 上的会让大多数用户挂起浏览器(少数从终端运行它的用户可以通过以下方式恢复)前景化,但仅此而已)。
Remote pages are not allowed to link to
file://
pages because it allows attacks on the browser, and in some cases on the OS. For example,<img src="file:///dev/tty">
on Linux will hang the browser for most users (the few running it from a terminal will be able to recover by foregrounding it, but that's it).无法通过 Web 应用程序读取本地文件,但是,您可以要求用户先上传文件,然后打开它。
It's not possible to read a local file through your web application, however, you can ask the user to upload the file first and then open it.