11-03-2005 06:39 PM - edited 03-15-2019 03:49 AM
Hi,
I want to use JavaScript to open/read TXT file and display content on the screen of the IP Phone.
This is my testing program:
set fs=CreateObject("Scripting.FileSystemObject");
set wfile=fs.OpenTextFile("zzz.txt");
wfile.close;
...but it does not work. I get HTTP 500 error.
When I use other java functions like Response.Write(), it works fine.
Is it something I have to do to have this thing working ?
Need to load java libraries ?
Paul
12-08-2005 10:42 PM
Hello Paul,
first of all I would like to say that I cannot help you with your problem. Sorry!
I only would like to know if you found a solution for your problem in the meantime, because I have the same problem and cannot solve it.
So if you found a solution it would be really kind of you to publish your results in the forum.
Thanks!
12-12-2005 02:04 PM
Hi,
Are you running it in .asp?
have you tried something like this?
<%
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile(Server.MapPath ("testread.txt"), 1)
Response.Write(f.ReadAll)
f.Close
%>
..just tested and it worked...
12-12-2005 04:40 PM
Hello,
in the meantime I cracked it too, but thank you very much for your help.
I found a very good website (http://www.html-world.de/program/fso_3.php -> German) where all the different functions of the FileSystemObject are explained.
In this context I found out that my problem was not a wrong code, my problem was a lack of access rights to the txt-file :-).
12-13-2005 01:07 AM
That's quite a common mistake because webservers use a less privileged account. It's not such good practice to access files outside the restricted permissions though, unless properly done it can open holes in your security.
12-13-2005 04:19 PM
Hi,
Thank you for response.
Yes.I was running in asp. When I tested your sample script, I got HTTP error 404. Seems that first line is problamatic and the system does not know how to create the object.
Did you have to run something specific on WEB server or maybe extra processes to have this script correctly activated ?
Paul
12-13-2005 06:52 PM
Hello Paul,
in your first request you wrote that you use JavaScript in your asp-file. Or not?
Maybe then you should try something like this:
fso = new ActiveXObject("Scripting.FileSystemObject");
a = fso.GetFile('C:/Name.txt');
b = a.OpenAsTextStream(modus,format);
c = b.ReadAll();
modus = 1 (read only), 2 (write only), 8 (attach text)
format = -1 -> Unicode; 0 -> ASCII; -2 -> system configuration
I hope you'll find a solution.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide