Hi Ken,
For the sake of other users facing the same problem, here is my (incomplete) solution:
- Get the FilePath property. This contains the full path of the uploaded file in the temporary folder
- Get the FileName property. This contains the original filename
- Check it a file with the name as the value of the FileName property already exists in the SaveFolder
- If so - copy the file from the temporary directory to the SaveFolder with a new unique name
- Else, do nothing, you can use the FileName property / file gets properly uploaded
Note: the ASPUpload component also persists the uploaded file in the SaveFolder using a unique filename in case of a duplicate. If you wish to delete this (obsolete) file, perhaps you could do some magic with the timestamp of files in the SaveFile location. I didn't.
My script looks something like this:
- Function UniqueFileAppendString()
- UniqueFileAppendString = "_" &_
- CStr(Year(Now)) & CStr(Month(Now)) & CStr(Day(Now)) & "_" &_
- CStr(Minute(Now)) & "_" &_
- CStr(Second(Now))
- End Function
-
- If Request.Form("uploader")&""<>"" Then
- Dim mvcfile, newFileName, filePath
- Set mvcfile=uploader.GetUploadedFile(Request.Form("uploader"))
- newFileName = mvcfile.FileName
- filePath = mvcfile.FilePath
-
- If FileExists(newFileName) = True Then
-
- newFileName = Left(mvcfile.FileName, InStrRev(mvcfile.FileName, ".") -1) & _
- UniqueFileAppendString() & _
- Right(mvcfile.FileName, InStrRev(mvcfile.FileName, ".") +1 )
-
-
- Dim fso, file
- Set fso = Server.CreateObject("Scripting.FileSystemObject")
- Set file = fso.GetFile(filePath)
-
- file.Copy Server.MapPath(uploadURL & newFileName), true
- Set fso = Nothing
- Set file = Nothing
- End If
-
- Set mvcfile = Nothing
-
- End If
Regards,
Nico