Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create file on the Client Side

Status
Not open for further replies.

philcp

Programmer
Jul 16, 2001
7
MY
Hi there,

I am trying to create a log file on the client everytime an asp is being accessed.

How can I do that?

I know that creating file on the server is possible e.g.

<html>
<head><title>Write File</title></head>
<body>
Writing File
<%
Set MyFileObject=CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set MyTextFile=MyFileObject.CreateTextFile(&quot;c:\log\test.txt&quot;)
MyTextFile.WriteLine(&quot;Hello There!&quot;)
MyTextFile.Close
%>
</body>
</html>

but what about creating it on the client????

The file can be of any extension. Preferbly of *.*log
 
That really depends on whether you are on an Intranet, or the Internet ...

If it's an Intranet, then you can set up special permissions for your server to write to the client machine -- you'll need to talk to your server's admin to get that set up properly.

If it's on the Internet, then you can't do that. The only file(s) that you have write access to on the client's machine is the cookie file(s)... it's a security precaution of all browsers.
penny.gif
penny.gif
 
well i'd be doing it on an intranet enviroment. how would i have to code it then?
is the coding that i have given above correct?
i've tried the one below, but i doesn't work

<script language=&quot;vbscript&quot;>
var FileObject, FileHandler

FileObject = new ActiveXObject(&quot;Scripting.FileSystemObject&quot;)

FileHandler = fs.CreateTextFile(&quot;c:\\log\\testfile.txt&quot;)
FileHandler.WriteLine(&quot;Some Text or u can pass this text from ASP&quot;)
FileHandler.Close()

</script>
 
No, your fs.createTextFile jazz will have to be a network path pointing to your user's computer...

ASP is server side scripting, and so when it's executing, if you give it c:\, it sees that as itself... does that make sense?

It has no idea that you are trying to tell it to look at the client's computer.

So you'd need something like this:

(&quot;\\computerName\shareNamePath\fileName.txt&quot;)

for your path so that your server will know where to go.

Like I said, though, you're probably gonna run into some permissions problems, but you should be able to get them sorted out if you have control over the computers.

:)
paul
penny.gif
penny.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top