Write local file with jQuery or Javascript

2019-01-28 02:51发布

I am creating a prototype that will be run in a web browser. I would like to store (and retrieve) various info submitted by a user during the use of the prototype. I know I can retrieve a variety of file formats such as xml, json... and I know I can do local storage using the plugin jstore. So I suppose I can do a convoluted solution where I get the first xml load from a starter file and then use local storage after it is manipulated and just check for local storage.

I do not want to use PHP or ASP or other scripts as I need to be able to share the prototype with senior execs who will not have webservers running and I do not want to install the prototype on the webserver... but perhaps that is the best way to do this as I know javascript can not write to the local file system for security reasons. On the otherhand maybe I am making the combination of getting the initial xml and using the jstore plugin sound harder than it really is.

4条回答
我只想做你的唯一
2楼-- · 2019-01-28 03:37

If the limitations of using Internet Explorer and all those issues of trust (permission to write to a users file system using javascript is probably only ever going to be possible on an intranet) then you can use the Scripting.fileSystemObject as per this msdn page.

查看更多
ゆ 、 Hurt°
3楼-- · 2019-01-28 03:38

The web platform is specifically designed to prevent sites from writing arbitrary data to client machines. There are a few exceptions to this that you can explore:

  • A plugin like Google Gears; or data store in HTML5 (not widely available) (easily lost)
  • Cookies (easily lost)
  • URL (limited by length, easily lost)
  • Files (more conventional albeit clumsy)

The web clearly operates better from a server. If you are hoping to deploy desktop installs, you can deploy a thick application that uses a lot of browser-based UI. That app could easily have access to the local system for files, etc. If a possibility, please comment.

查看更多
狗以群分
4楼-- · 2019-01-28 03:47

I agree with all the opinion that it is difficult to store data in client side using JavaScript. If we have to create a stand alone application then adobe air seems to be promising. As per specs and features stated by adobe we can use JavaScript and html skill to create an application also it allows you to read /write to a local storage in file or database.

查看更多
Lonely孤独者°
5楼-- · 2019-01-28 03:54

You can use flash for storing data. By default it allows you store up to 100 kb and you can have more with getting permission from user.

You can find more information from google

查看更多
登录 后发表回答