ASP FileSystemObject Upload.

A

Alex

I am having issues with a script to upload files from a client to a
webserver. The problem is not with the actual upload but with where it
uploads. The whole process is supposed to create a folder (it does)
then upload the file to that folder and this is where the problem comes
in. The file is written to the parent directory, not the directory
that was created for this user. Following is the code.

<%

strFTProotFolder = "c:\web\upload\share" 'file is saved here


Set DirectoryObject = Server.CreateObject("Scripting.FileSystemObject")
Set Upload = Server.CreateObject("Persits.Upload")

If Not DirectoryObject.FolderExists(strFTProotFolder & "\" &
upload.form("RequestID") Then
response.write("Error: Folder Does Not Exist!")
Else
strUploadTo = strFTProotFolder & "\" & upload.form("RequestID") 'file
is supposed to be saved here
Count = Upload.Save(strUploadTo)
Set file = Upload.Files("file1")
Response.Write(Count & " file uploaded.<br>")
Response.Write(upload.form("RequestID") & "<br>")
For Each File in Upload.Files
Response.Write(File.OriginalFileName & " (" & File.Size &"
bytes)<br>")
Next

End If

%>

I think the problem has to do with the 'RequestID' variable. It is
empty until after this line " Count = Upload.Save(strUploadTo) ". I
don't understand why it isn't populated until then. I had it print the
value of said variable every other line to see what it's value was
through the process.
 
M

Michael Kujawa

I would think you would create the folder when creating
the client record instead of during an upload routine

However you said the folder is created during the process
and I see nothing that creates a folder in the syntax;
A line like
Set ClientFolder = DirectoryObject.CreateFolder(strFTProotFolder & "\" &
Session("RequestID") )
unless there is more code somewhere.

I would not rely on a method that has to wait until it is finished
especially when you are relying on it to create other things.
when the user logs on create a session("RequestID") variable
and use that in the upload routine instead of the Upload.form value
which is not available until after the upload completes.
 

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

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top