Log in

View Full Version : I want to be able to open a plain text file in JAVASCRIPT and be able to read as text



Deepa
07-12-2010, 06:27 AM
I want to be able to open a plain text file in JAVASCRIPT and be able to read as text. .


I able to write text in .text file But i cant able to read or open file.here is javascript code...Please advice.

<script language="javascript" type="text/javascript">
var fso, ts;
var ForWriting= 2;
fso = new ActiveXObject("Scripting.FileSystemObject");
ts = fso.CreateTextFile("c:\\test.txt", 2, true,0);
ts.Close();
ts.write("ia javascript");
var ForReading = 1, openfile;
openfile = fso.OpenTextFile("c:\\test.txt", 1);
if(openfile =-1)
{
var obj = openfile.ReadAll();
//var obj = openfile.ReadLine();
Response.Write("File contents:" +obj);
}


</script>

djr33
07-12-2010, 01:31 PM
Why is this in the mysql section? Is this not a JavaScript question? It should be posted there.