Click to See Complete Forum and Search --> : help with asp upload


esthera
11-17-2005, 04:56 AM
I have the following code:


Set Upload = Server.CreateObject("Persits.Upload")
Upload.OverwriteFiles = False
Upload.SetMaxSize 3000000, True

On Error Resume Next
path= server.mappath("admin.asp")
path=left(path,len(path)-10)
path=path & "\pictures\"
Count = Upload.Save(path)
If Err <> 0 or Count = 0 Then
if err<>0 then Response.Write "An error occurred:" & Err.Description
Else
On Error Goto 0
Set File = Upload.Files(1)
If File.ImageType = "UNKNOWN" Then
File.Delete
response.write "This is not a valid image file."
end if
fName = File.ExtractFileName'right(file.path,len(file.path) - slashLoc)

end if



I now want to add to my form a picture2 that will go to my pictures2 directory instead of pictures.
I also need to extract the second filename.

Can someone help me edit this?

Giskard
11-17-2005, 04:20 PM
Not sure if i understand your question completely. If you want to upload two files at the same time to two different directories you could add this code to the end of your code:

path= server.mappath("admin.asp")
path=left(path,len(path)-10)
path=path & "\pictures2\" ' <---- set the path to the second directory
Count = Upload.Save(path)
If Err <> 0 or Count = 0 Then
if err<>0 then Response.Write "An error occurred:" & Err.Description
Else
On Error Goto 0
Set File = Upload.Files(2) ' <---- Get the second filename
If File.ImageType = "UNKNOWN" Then
File.Delete
response.write "This is not a valid image file."
end if
fName = File.ExtractFileName'right(file.path,len(file.path) - slashLoc)

end if

buntine
11-17-2005, 08:50 PM
The indexing will most likely start at 0. So the first filename would be retrieved via Upload.Files(0). And the second; Upload.Files(1).

;)

esthera
11-20-2005, 04:21 AM
I get an error: Persits.Upload.1 error '800a003e'

Save method must not be called more than once.


Also will this error out if the second picture is empty. (it is not mandatory)