Jump to content

How to write to a *.txt file.


vmars316
 Share

Recommended Posts

Greetings;How to write to a *.txt file, Browser independent.I can read it into iFrame: (not sure about TextArea though) <iframe src="vmars.txt" style="float: right; width: 260px; height: 130px; margin-left: 12px; border: 1px solid black;" name="#vmarsTXT"></iframe>but how to write it back out? Into *.txt . Not into Cookies, but a real *.txt file.Thanks...vmars

Link to comment
Share on other sites

Far as I know, JavaScript can't write to any kind of file (except cookies). You'd need a server-side language for that.
1) Can a server-side language run on client-side?2) If so, which ones? Browser independent?3) I guess I want to rePhrase my request:"How to write to a *.txt file, FROM a TEXTAREA and/or FROM an iFrame"? 4) Since my original request, I did find this(untested):var fso,filefso = newActiveXObject("Scripting.FileSystemObject")file=fso.CreateTextFile("C:\\a.txt")file.close(); 5) But I want to write the 'whole text' FROM a TEXTAREA and/or FROM an iFrame,NOT just one line. If I have to write a line at a time, Can TEXTAREA and iFrame be accessed by index. Thanks...vmars
Link to comment
Share on other sites

that's why its called a server-side scripting language...it only runs off the server.You would probably want to use AJAX to pass off the value of the textarea (by using Javascript - which runs on the client side) and use PHP (or something similar) to write to a file on the server.edit: now that I think about it, you don't need to use AJAX. Simply using PHP for everything would work, even as simple as a form passing lots of text to a PHP file set to receive the text and write to the appropriate file on the server.

Edited by thescientist
Link to comment
Share on other sites

You would probably want to use AJAX to pass off the value of the textarea (by using Javascript - which runs on the client side) and use PHP (or something similar) to write to a file on the server.
Which I think you can then pass back to JavaScript and read the contents with JavaScript.
Link to comment
Share on other sites

You aren't allowed to write files onto the client computer, for the simple reason that it would allow anybody to put viruses on your computer from any website.

Link to comment
Share on other sites

oh yeah, I just noticed that in his post

var fso,filefso = newActiveXObject("Scripting.FileSystemObject")[b]file=fso.CreateTextFile("C:\\a.txt")[/b]file.close();

yeah, you can't do that.

Link to comment
Share on other sites

.but the only use for something like that would be an application you're writing for yourself, not for others.
Yes, that's exaclty what I want to do, Locally. But for all Browsers!The next best thing is ClipBoard. But I haven't yet found a way to make ClipBoard 'Browser independent'.Do you know of a way?So, I think that leaves 'Save stuff via cookies'. Which seem to be Browser independent.Am I right about that?Thanks...vmars316 Edited by vmars316
Link to comment
Share on other sites

are you sure you understood JSG's post? I think what he's saying is you can't do it through a browser; however IE will, but only if it's an application running locally, on someone's computer. (not via the web in a browser).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...