从HTML5桌面应用程序访问html文件夹中的本地文件 [英] Access local files from HTML5 Desktop Application in html folder

查看:344
本文介绍了从HTML5桌面应用程序访问html文件夹中的本地文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



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



所以请让我知道:


  1. 可以使用特定的命令运行浏览器来强制它允许访问存在于同一个HTML文件夹中的本地文件?它不应该禁用所有的本地安全限制只是授予在同一文件夹或子文件夹中的文件的HTML访问。
  2. 跨平台的方法是将本地文件夹映射为在移动平台上工作的本地主机?

  3. 是否有任何清单文件存在可放入文件夹以授予相同HTML文件夹中的读取访问权限?

  4. 是否有任何方法来授予只读作为沙箱访问文件夹?

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



任何想法都是值得欢迎的。

解决方案

如果你需要这个文件,为什么不把它加载到JS脚本中作为json对象。

因此,换句话说,将文件的内容放入一个js脚本中,并将文件内容转换为JSON格式,然后在加载时加载该脚本或者当你需要的时候。



另外,如果你需要文件IO使用本地存储。


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.

解决方案

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.

这篇关于从HTML5桌面应用程序访问html文件夹中的本地文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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