html - 从 firefox 打开硬盘驱动器上的直接文件(文件 :///)

标签 html security firefox web-applications

我有一个为自己创建的小型 php 系统。该系统包含一些.doc 和.docx 文件文档。我希望能够直接从浏览器打开它们,而不是下载它们。

我创建了一个链接: <a href="file:///c:/mysite/myfile.docx">myfile</a> 但是 FireFox 不会打开链接。同时 href="http://localhost/myfile.docx"工作正常 - 它让我下载文件。

我该怎么做? 也许更改 firfox 选项/安全设置中的某些内容? 如果您愿意,是否有机会在 IE8 中做到这一点?

谢谢。

最佳答案

虽然我仍然认为这是一道编程题,但在这里得到了解答: https://superuser.com/questions/103026/open-a-direct-file-on-the-hard-drive-from-firefox-file

Firefox 和 IE8 都支持 File URI scheme .

Here are some examples valid for Windows systems, referring to the same file c:\WINDOWS\clock.avi

file://localhost/c|/WINDOWS/clock.avi
file:///c|/WINDOWS/clock.avi
file://localhost/c:/WINDOWS/clock.avi
file:///c:/WINDOWS/clock.avi

虽然最后一个是最明显的 人类可读的,第一个是 最完整和正确的。

显然(来自相同的 url):

Mozilla browsers refuse to follow file URLs on a page that it has fetched with the HTTP protocol.

但是:

Mozilla browsers can be configured to override this security restriction as detailed in Mozillazine's "Links to Local Pages Don't Work".

关于html - 从 firefox 打开硬盘驱动器上的直接文件(文件 :///),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2148584/

相关文章:

html - CSS 背景颜色在谷歌浏览器中给出奇怪的结果

javascript - 从选择中获取选定值并发布到 MySQL 表

html - 有哪些 HTML 表单攻击媒介?

java - Android Realm 数据库安全

html - Firefox 不会用图像包裹 div

javascript - jQuery - $(document).ready 未准备好

javascript - 模板助手中的 Meteor QuickForm 异常 : Error: Recipes is not in the window scope

html - 从标题菜单中分离 Logo 并将其放在标题和正文的第一部分之间

javascript - 使用 JavaScript 将类添加到可悬停元素

ruby - 与其他方法相比,ruby 中 rand 的安全性