HTML5 是否允许您从浏览器中与本地客户端文件进行交互 [英] Does HTML5 allow you to interact with local client files from within a browser

查看:18
本文介绍了HTML5 是否允许您从浏览器中与本地客户端文件进行交互的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过一些关于通过网页访问客户端机器上的文件的帖子,即这个 问题.

I've seen some posts regarding access to files on a client machine by a webpage, namely this question.

对于我正在编写的某些算法,我正在尝试采用在云中持续更新"的范例,以便我的用户只需访问网页即可访问最新版本.这要求程序/网页可以从一个目录开始并递归检查其中的文件并根据找到的内容计算结果.最后它也应该能够将结果文件写入客户端的文件系统.

I'm trying to hop on the "continuously update in the cloud" paradigm for some algorithms I am writing so my users can access the latest versions by simply accessing the webpage. This requires that the program/webpage can start with a directory and recursively inspect files within it and compute results based on what is found. In the end it also should be able to write the results file to the client's filesystem.

上一个问题中的一个答案提到了 Google Gears,但此后已停止支持 HTML5.是否可以在 HTML5 中访问客户端目录?怎么样?

One of the answers in that previous question mentions Google Gears but that has since been discontinued in favor of HTML5. Is access to a client directory possible within HTML5? How?

我知道为什么通过任何网页访问本地文件存在安全风险,但出于我的目的,我可以向用户询问适当的权限.

I know why access by any webpage to local files is a security risk, but for my purpose I have no problem to ask the user for the appropriate permissions.

推荐答案

不,至少不是直接的.但是,您在这里有多种选择.

No, not directly at least. However, you have a number of choices here.

目前您的最佳选择是:

  • 从桌面拖放文件,参见 教程.(链接因恶意软件/网络钓鱼而被禁用)
  • 使用输入类型文件.
    • 使用文件 API 阅读内容或提交表单.详细了解 Mozilla 开发人员中心,了解动态读取文件.
    • 您可以指定 multiple 属性来一次读取和打开多个文件,而不必有单独的字段.
    • 您可以有一个不可见的输入和触发点击";在它上面打开文件打开对话框.有关详细信息,请参阅之前的 Mozilla 开发人员中心链接.
    • Drag and drop files from desktop, see a tutorial. (Link disabled for malware/phishing)
    • Use input type file.
      • Read the contents with the File API or submit the form. Read more on Mozilla Developer Center about reading the file dynamically.
      • You can specify multiple attribute to read and open multiple files at once without having to have separate fields.
      • You can have an invisible input and "trigger a click" on it to open the file open dialog. See the previous Mozilla Developer Center link for details.

      这篇关于HTML5 是否允许您从浏览器中与本地客户端文件进行交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆