ASP creating & writing to text file error

T

Tracy

I am using ASP to write a text file and then email it. The data also
goes into a sql table (this works fine).
The error is a runtime error and says that the path cannot be found.
Any help would be appreciated!!! Thanks
here is the code:

Function WriteTextFile()


Dim STR

Dim filesys 'Dimension Variables required for File Output
Dim filetxt
Dim getname
Dim path


Set filesys = CreateObject("Scripting.FileSystemObject")
ERROR*** Set filetxt =
filesys.CreateTextFile("c:\www\curtisind.com\" & request.Form("name")
& ".txt", True)

'path = filesys.GetAbsolutePathName("c:\www\curtisind.com\" &
request.Form("name") & ".txt")
'getname = filesys.GetFileName(path)

filetxt.WriteLine(" ")
filetxt.WriteLine(" ")
filetxt.WriteLine(" ")
filetxt.WriteLine(" ")
filetxt.WriteLine("Name: " & Request.Form("name"))
filetxt.WriteLine("Company: " & Request.Form("company"))
filetxt.WriteLine("Email: " & Request.Form("email"))
filetxt.WriteLine("Phone Number: " & Request.Form("phone"))
filetxt.WriteLine("Password: " & Request.Form("password"))
filetxt.WriteLine("Confirm Pasword: " & Request.Form("password2"))

filetxt.WriteLine("----------------------------------------------------------------------------")

filetxt.Close

WriteTextFile = True

End Function
 
R

Ray at

1. Does C:\www\curtisind.com path exist on the server?
2. You should put the contents of Request.Form("name") in a variable,
validate that it's a valid value and then use that. That would be much
preferred over pulling request.form("name") twice and then using
filesys.GetFilename to get the value once again. And if the value is blank
or has invalid characters, your code will fail when it tries to create the
file.

Also make sure that your IUSR account has NTFS permissions to create a file
in this path.

Ray at work
 
T

tracy koehler

1. the path does exist on the server.
2. I stored the request.form("name") into NAME and used that. Nothing.

?I'm not sure what IUSR account is.
Also make sure that your IUSR account has NTFS permissions to create a
file
in this path.

Tracy
 
R

Ray at

tracy koehler said:
1. the path does exist on the server.
Okay.


2. I stored the request.form("name") into NAME and used that. Nothing.

Where? Do a Response.Write path before you try to create the file.

?I'm not sure what IUSR account is.

It's the account that is used on the server to run the code in the ASP
pages, in a default configuration. It's a user account, just like tkoehler,
if that's what your username is. This user account needs permissions to
create files in this path.



The reward is that the threads are next to impossible to follow and people
often drop out of these threads that are carried out through developersdex.

Ray at work
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top