Can Javascript produce a file?

R

Richard Cornford

mydirac said:
I'm thinking about javascript's producing another file.
Can I do it?

JavaScript can write files but only indirectly and only in some
environments. From an (unspecified) web browser writing to the client's
files system would be a security violation and is close to being
impossible, certainly not worth the effort.

It should be possible to provide something like a Java applet what would
permit the writing of a file to your server and be scriptable with
JavaScript. Doing so would be massively stupid as such an applet would
be trivial to hijack and you would not want some remote user to be able
to choose to write anything they wanted to your server.

The normal HTML form/HTTP based request to server, sending information
that may be placed in, or added to, a file and server-side scripting to
check that information and then file it, is the only sensible approach
as you get to choose what control to place on what is written to your
server/databases (and the client cannot ascertain any of the details).

Richard.
 
M

mydirac

Thank you, thank you so much for your detailed answer and explanations.
I need to study it deeper.
 
L

Laurent Bugnion, GalaSoft

Hi Richard,

Richard said:
JavaScript can write files but only indirectly and only in some
environments. From an (unspecified) web browser writing to the client's
files system would be a security violation and is close to being
impossible, certainly not worth the effort.

It should be possible to provide something like a Java applet what would
permit the writing of a file to your server and be scriptable with
JavaScript.

Unless I am very mistaken, this is impossible without some kind of
server-side interaction. Applets are able to open direct connections to
the server (in the contrary of JavaScript, which goes through the HTTP
protocol), but it is not enough to allow writing to it. The usual way to
handle this is a pair applet-servlet.


Doing so would be massively stupid as such an applet would
be trivial to hijack and you would not want some remote user to be able
to choose to write anything they wanted to your server.

The normal HTML form/HTTP based request to server, sending information
that may be placed in, or added to, a file and server-side scripting to
check that information and then file it, is the only sensible approach
as you get to choose what control to place on what is written to your
server/databases (and the client cannot ascertain any of the details).

Richard.


Laurent
 

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

Forum statistics

Threads
474,076
Messages
2,570,565
Members
47,200
Latest member
Vanessa98N

Latest Threads

Top