从 html 文件夹中的 HTML5 桌面应用程序访问本地文件

发布于 2025-01-05 00:07:26 字数 627 浏览 6 评论 0原文

HTML5 很棒,我可以用它替换我现有的桌面应用程序,但一点点安全限制就阻止我完成我的工作。我计划完全使用 HTML5 创建一个简单的桌面应用程序,以便它可以在任何支持 HTML-5 的移动和桌面设备上运行。

我了解本地文件的浏览器安全性及其背后的原因,但我不知道为什么我找不到一种方法来授予对沙盒文件夹的只读访问权限。我的应用程序不需要写入文件,甚至不需要读取主 html 文件夹之外的文件。它需要读取与域上相同的文件夹中的本地文件。

所以请让我知道:

  1. 可以使用特定命令运行浏览器以强制其授予对 HTML 同一文件夹中存在的本地文件的访问权限吗?它不应禁用所有本地安全限制,而应授予对同一文件夹或子文件夹中文件的 HTML 访问权限。
  2. 将本地文件夹映射为在移动平台上工作的本地主机是否是跨平台方法?
  3. 是否存在任何清单文件可以放入文件夹中以授予同一 HTML 文件夹中的读取访问权限?
  4. 有什么方法可以授予对沙盒文件夹的只读访问权限吗?

注意我不想使用第三方解决方案,例如 XULRunner、Mozilla Prism、Adobe Air 或任何其他第三方,我需要 HTML-5 解决方案跨平台(如果有) .

欢迎任何想法。

HTML5 is great and I can replace my existing desktop application with it, but just a little security restriction prevents me to complete my job. I plan to create a simple desktop application completely with HTML5 so it can run on any mobile and desktop devices that support HTML-5.

I know about the browser security on local file and the reason behind it, but I don’t know why I couldn’t find a way to grant read-only access to a folder as sandbox. My application does not need to write a file or even does not need to read a file outside of It main html folder. It needs to read the local file just in same folder same as it do on domain.

So please let me know:

  1. Can run browser with specific command to force it grant access to local file that exists in same folder of HTML? It should not disable all local security restriction just grant HTML access to file in same folder or subfolder.
  2. Is it cross platform method to map a local folder as local host that work on mobile platforms?
  3. Is there any manifest file exists to put in folder to grant read access in same HTML folder?
  4. Is there any way to grant read-only access to a folder as sandbox?

Note: I don't want use third party solution such as XULRunner, Mozilla Prism, Adobe Air or any other third party, I need HTML-5 solution to be cross platform if there is any.

Any idea is welcome.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

单身情人 2025-01-12 00:07:26

如果您非常需要该文​​件,为什么不将其作为 json 对象动态加载到 JS 脚本中呢?

因此,换句话说,将文件的内容放入 js 脚本中,并将文件内容构建为 JSON 格式,然后在加载时或需要时加载该脚本。

或者,如果您需要文件 IO,请使用本地存储。

If you need that file so much, why not just load it dynamically inside a JS script as a json object.

So, in other words, put the contents of the file into a js script, and strucutre the file contents into JSON format, then load that script on load or when you require it.

Alternately if you need file IO use localstorage.

趴在窗边数星星i 2025-01-12 00:07:26

根据 此网站,从带有参数 --allow-file-access-from-files 的 cmd 将禁用此安全功能

according to this site, launching chrome from the cmd with the parameter --allow-file-access-from-files will disable this security feature

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文