Creating files on client side using javascript

S

shailaja.sheel

Hi ,

This is my first attempt to do some html/javascript programming and I
am totally lost. I have a questionaire form and when user clicks
Submit, I want to save the data in XML file on client side. User will
then sync all these xml files to a PC later. From all the research I
have done so far, its being indicated that client side file creation
is not possible - is that true? If yes, then I have a huge problem -
is there anyway I can create these files? Any suggestion would be
really appreciated. PLease remeber that I am novice to all this.

Thanks
LostShoul!
 
G

GArlington

Hi ,

This is my first attempt to do some html/javascript programming and I
am totally lost. I have a questionaire form and when user clicks
Submit, I want to save the data in XML file on client side. User will
then sync all these xml files to a PC later. From all the research I
have done so far, its being indicated that client side file creation
is not possible - is that true?
Yes, you CAN NOT access client side file system with standard
javascript...
If yes, then I have a huge problem -
is there anyway I can create these files? Any suggestion would be
really appreciated. PLease remeber that I am novice to all this.
Once the form is posted you can create xml file on the server and send
it back to the client for download - i.e. your response to form post
maybe a generated xml file, or a page with a link to download one...
 
G

Gregor Kofler

(e-mail address removed) meinte:
Hi ,

This is my first attempt to do some html/javascript programming and I
am totally lost. I have a questionaire form and when user clicks
Submit, I want to save the data in XML file on client side. User will
then sync all these xml files to a PC later. From all the research I
have done so far, its being indicated that client side file creation
is not possible - is that true? If yes, then I have a huge problem -
is there anyway I can create these files? Any suggestion would be
really appreciated. PLease remeber that I am novice to all this.

I've just assembled a nice malicious program and want to deploy it to
trillions of clients. Put it on a website named "free p**n" and have it
delivered via JS. Does this sound like something you want to encounter
in the wild?

Bottom line: You can't access the clients filesystem (IE-only ActiveX
components that can access the filesystem exist). You can return your
clients response to the server (via a form) and process the responses
there. No JS needed for that.

Gregor
 
S

shailaja.sheel

I should have also mentioned that this will not be available to
everyone.
My target user will be aware of the xml creations and that this will
be
used on a PDA. Maybe there is someother way to create them on PDA?
Sending
data each time he/she submits may be not be a feasible option - maynot
have connection, maybe out range. There has to be some way to save it
on
PDA, so that it can be sent later.

thanks
LS
 
L

Lasse Reichstein Nielsen

This is my first attempt to do some html/javascript programming and I
am totally lost. I have a questionaire form and when user clicks
Submit, I want to save the data in XML file on client side.

As others have said, that is not generally possible.

There are ways around it that works in some browsers (or rather, there
are several ways around it that each work in one browser :), but at
least the user will be asked if the page should be allowed to access
the local disk.
If the user accepts, then it works, and if they are the ones to sync
later, then they'll probably cooperate.

TiddlyWiki can save itself in both IE and Mozilla/Firefox, and with
some setup also in Opera (and possibly other browsers too, as the
Opera solution uses Java). I looked at the code some time ago, and
with some fiddling, it should be possible to duplicate the effect.
See: http://www.tiddlywiki.com/#SaveChanges

Another option is to have the user install Google Gears, and store
the data in a database instead of a local file.

In either case, this will probably take an experienced programmer
some effort, so as a first-time user, you might be in over your
head.
/L
 
B

Bart Van der Donck

This is my  first attempt to do some html/javascript programming and I
am totally lost. I have a questionaire form and when user clicks
Submit, I want to save the data in XML file on client side. User will
then sync all these xml files to a PC later. From all the research I
have done so far, its being indicated that client side file creation
is not possible - is that true? If yes, then I have a huge problem -
is there anyway I can create these files?

IE4+:

<iframe name="ifr" style="display:none; visibility:hidden"></iframe>
<form method="get" action="#" onSubmit="return false">
Email <input type="text" name="email" size="20"><br>
Tel <input type="text" name="tel" size="20"><br>
<input type="button" value="Save" onClick="
if (document.execCommand) {
var w = frames['ifr'].document;
w.open('text/xml', 'replace');
w.write('<?xml version=\'1.0\' encoding=\'UTF-8\'?>\n'
+ '<root>\n'
+ ' <email>' + document.forms[0].email.value + '</email>\n'
+ ' <tel>' + document.forms[0].tel.value + '</tel>\n'
+ '</root>');
w.close() ;
w.execCommand('SaveAs', true, 'yourfilename.xml');
}
else {
alert('document.execCommand is only supported in MSIE4+.');
}
">
</form>

Hope this helps,
 
G

GArlington

GArlington said:
[...] From all the research I have done so far, its being indicated
that client side file creation is not possible - is that true?
Yes, you CAN NOT access client side file system with standard
javascript...

And what would this "standard javascript" of yours be?
I trust that MS Jscript (which is often referred to as javascript
[variant]) allows client file system access...
 
T

Thomas 'PointedEars' Lahn

GArlington said:
Thomas said:
GArlington said:
On Jun 20, 9:37 am, (e-mail address removed) wrote:
[...] From all the research I have done so far, its being indicated
that client side file creation is not possible - is that true?
Yes, you CAN NOT access client side file system with standard
javascript...
And what would this "standard javascript" of yours be?
I trust that MS Jscript (which is often referred to as javascript
[variant]) allows client file system access...
[trolling snipped]

Please don't post here again until you have a minimum clue what you are
talking about (and learned how to quote properly). Thanks in advance.


Score adjusted

PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top