PDA

View Full Version : Client side file i/o with JS?


Nomadicus
11-24-2002, 04:37 PM
Does JS provide any methods for client side file i/o? I would like to be able to store small amounts of information, e.g. set-up preferences, in a text file and send this info to the server, on request.

I've tried using cookies for this, but it gets a little too complicated for what I have in mind. A simple text file would be a snap, but I don't want to store that text file on my server when it could just as easily be stored on the user's machine.

redhead
11-24-2002, 05:15 PM
nope... you'll have to stick to cookies. javascript cant create/edit/access files...

premshree
11-25-2002, 04:55 AM
Well, it is possible to acces files in JavaScript. (You can access XML files in JS) but manipulation is not possible. You will need a server-side scripting language.

ConfusedOfLife
11-25-2002, 08:56 AM
Check this out:

http://www.codingforums.com/showthread.php?s=&postid=48498#post48498

Roelf
11-25-2002, 09:33 AM
As described in the thread ConfusedOfLife mentioned is, it can be done, not exactly javascript accessing files, but javascript interacting with an ActiveX object which in return accesses files (but hey, what´s the difference). There is a catch though, some people have their security set very strict, and therefor the active-X object isnt always created by the brower. I dont know for sure netscape and other non-IE browsers can instantiate acive-x objects, but if they cannot do that, the whole ballgame doesnt work. So be sure you make some errorhandling in the script.

but for the functionality you want, cookies are fine

I've tried using cookies for this, but it gets a little too complicated for what I have in mind. A simple text file would be a snap, but I don't want to store that text file on my server when it could just as easily be stored on the user's machine.

cookies are simple text files :D

premshree
11-25-2002, 09:44 AM
Right..........why take a chance trying to access files using a client-side script...It makes sense to use a server-side scripting lang......