In article <mq********************************@4ax.com>, swl773
@hotZmail.com enlightened us with...
OK, I know I can't read a file with JavaScript, but I see references
that I can use the filesystemobject which is part of vb script. Can I
embed vb script in HTML?
Yes, but only IE understands it. I prefer JScript, and this is a
javascript group after all. JScript is also IE only. (It may work with
javascript, too, but I didn't check)
I am writing a program for company internal use that will extract
information from a drawing on the user's local workstation and then
needs to convey that information to a web app communicating to the
user through their brower. Everything is pretty much microsoft tho'
we don't use IIS but are using the web serving capabilities of
weblogic.
The server is irrelevant for reading client-side files.
Any suggestions for how to get that file's contents (probably less
than 1K) into the web app would be greatly appreciated. I don't mind
doing some digging here but point me in the right direction, please.
The following reads a text file from the user's (client) machine with
JScript and writes the contents to a div. Watch for word-wrap.
[note that the following generates an ActiveX warning]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title> Read client file with JScript </title>
</head>
<body>
<script language="JScript" type="text/jscript">
function ReadFile(filename)
{
var fso, f;
var ForReading = 1;
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.OpenTextFile(filename,
ForReading);
txtbox.innerText = f.ReadAll();
f.close()
}
</script>
<BUTTON style="border: 1px outset; width:100px" onClick="ReadFile('c:
\\test.txt');">
Read File</BUTTON>
<div id="txtbox"></div>
</body>
</html>
I made a simple text file and saved it to c:\\test.txt.
Contents of text.txt:
this is a test file
with some contents in it
for testing
file IO
--
--
~kaeli~
Is it true that cannibals don't eat clowns because they
taste funny?
http://www.ipwebdesign.net/wildAtHeart http://www.ipwebdesign.net/kaelisSpace