Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access local files from HTML5 Desktop Application in html folder

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.

like image 363
Mohammad Nikravan Avatar asked Feb 12 '12 17:02

Mohammad Nikravan


1 Answers

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.

like image 51
Cris Stringfellow Avatar answered Sep 22 '22 17:09

Cris Stringfellow