By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,287 Members | 1,581 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,287 IT Pros & Developers. It's quick & easy.

Can Javascript produce a file?

P: n/a
hello,
I'm thinking about javascript's producing another file.
Can I do it?
Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"mydirac" <my*****@siren.ocn.ne.jp> wrote in message
news:be*********@nn-tk102.ocn.ad.jp...
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.
Jul 20 '05 #2

P: n/a
Thank you, thank you so much for your detailed answer and explanations.
I need to study it deeper.
"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message
news:be*******************@news.demon.co.uk...
"mydirac" <my*****@siren.ocn.ne.jp> wrote in message
news:be*********@nn-tk102.ocn.ad.jp...
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.


Jul 20 '05 #3

P: n/a
Hi Richard,

Richard Cornford wrote:
"mydirac" <my*****@siren.ocn.ne.jp> wrote in message
news:be*********@nn-tk102.ocn.ad.jp...
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.


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
--
Laurent Bugnion, GalaSoft
Webdesign, Java, javascript: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch

Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.