View Full Version : Write Text Files to Local Machine
mbock11
09-24-2004, 05:44 PM
I need to know how to write a text file to a local machine. Here is my code:
Set myFSO = Server.CreateObject("Scripting.FileSystemObject")
Set WriteText = MyDrive.CreateTextFile("C:\test.txt", True, False)
Right now it writes the file to the C: drive on the server. Please help!
Roy Sinclair
09-24-2004, 08:37 PM
Of course it writes files on the server, ASP is a Server side language (ie it runs on the server) so any files it writes are written to the server.
So what runs on the client? The browser runs on the client side and one of the things the browser does is NOT allow you to write files to arbitrary locations on a clients machine. If the browser did allow that then the delivery of viruses would be so simple that nobody in the world could connect the to internet without expect to have their machine infected.
Whatever you need to do, this isn't the way you're going to accomplish it. You can however provide a download link to the file and let the users download it to the location of their choice.
mbock11
09-24-2004, 09:22 PM
Okay, I understand that now. So then how would I go about allowing the user to download the file from the server?
Roy Sinclair
09-24-2004, 09:35 PM
The usual method is to place the file on a FTP server and use an FTP url to reference the file. That will cause it to be downloaded when the user clicks on the link.
<a href="ftp://aserverwithftp/pathtothefile/thefilename">Download a file</a>
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.