By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,490 Members | 1,398 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,490 IT Pros & Developers. It's quick & easy.

Reading a file

P: n/a
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?

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.

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.

TIA

Steve
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

"Steve" <sw****@hotZmail.com> wrote in message news:mq********************************@4ax.com...
OK, I know I can't read a file with JavaScript, but I see references
Not true. The FileSystemObject is availabel to JScript and JavaScript, instantiated as an ActiveX
object. For Internal use, look at putting your code in an HTA to avoid the Security constraints imposed
by the browser environment.
that I can use the filesystemobject which is part of vb script. Can I
embed vb script in HTML?

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.

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.

TIA

Steve

Jul 23 '05 #2

P: n/a
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

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.