Reading a file on the local machine with javascript -
I am new to javascript What am I trying to do: Write a script, which reads a php or txt file,
Take the information (a number), and replace it on a page like a banner. It will be something like ratings, and this rating will be on the local machine.
I need some scripts that will work with most browsers.
Thanks for your help !!!
Only Internet Explorer supports this through ActiveXObject. You can access the file system using ActiveXObject and then read the file.
View:
Function readfile () {var fso, F1, ts, s; Var ForReading = 1; Fso = new ActiveXObject ("Scripting.FileSystemObject"); F1 = fso.CreateTextFile ("c: \\ testfile.txt", true); // Write a line Response.Write ("writing file
"); F1.WriteLine ("Hello World"); F1.WriteBlankLines (1); F1.Close (); // Read the contents of the file Response.Write ("Reading the file
"); Ts = fso.OpenTextFile ("c: \\ testfile.txt", for readings); S = ts.ReadLine (); reaction. Type ("file content =" "+ s +" ''); Ts.Close (); }
Comments
Post a Comment