You can use FSO (File System Object) to read and write text files. To create a text file the first step is to assign data to the variable you will be using for the files path and text. We use the server.mappath to determine the current location (the directory we launched the ASP page from). We use the current path location so that the text file is saved in the same directory. The variable new_text contains the text to be saved in the file. The new_text variable was obtained from an HTML form. The name of the field in this example is form_field. Of course it would be whatever name you gave the input or textarea form element. In order for this to work you have to submit the form to the ASP page containg this code.<BR><BR><%<BR>new_text = request.form("form_field")<BR>Set Bob = CreateObject("Scripting.FileSystemObject")<BR>theP ath = server.mappath("text_file.txt")<BR>Set Bob1 = Bob.CreateTextFile(thePath, True)<BR>Bob1.WriteLine(new_text)<BR>Bob1.Close<BR >Bob.Close<BR>%>
First, you should check whether or not you have permission to write on the server. If you do have it, you have a problem with <BR>your mappath. You can try to have this instead<BR>thepath="drivename:... extfile.txt"<BR>Remember that drivename is from the server, not from the client machine.