从HTML5桌面应用程序访问html文件夹中的本地文件 [英] Access local files from HTML5 Desktop Application in html folder
问题描述
我知道浏览器本地安全文件及其背后的原因,但我不知道为什么我找不到一种方法来授予对沙箱的只读访问权限。我的应用程序不需要写一个文件,甚至不需要读取它的主html文件夹外的文件。它需要读取本地文件只是在相同的文件夹相同,因为它在域上。
所以请让我知道:
- 可以使用特定的命令运行浏览器来强制它允许访问存在于同一个HTML文件夹中的本地文件?它不应该禁用所有的本地安全限制只是授予在同一文件夹或子文件夹中的文件的HTML访问。
- 跨平台的方法是将本地文件夹映射为在移动平台上工作的本地主机?
- 是否有任何清单文件存在可放入文件夹以授予相同HTML文件夹中的读取访问权限?
- 是否有任何方法来授予只读作为沙箱访问文件夹?
注意:我不想使用第三方解决方案如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:
- 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.
- Is it cross platform method to map a local folder as local host that work on mobile platforms?
- Is there any manifest file exists to put in folder to grant read access in same HTML folder?
- 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屋!