There's a section of the freeaspuload code that looks like this:
Code:
Public Sub Save(path)
Dim streamFile, fileItem
if Right(path, 1) <> "\" then path = path & "\"
if not uploadedYet then Upload
For Each fileItem In UploadedFiles.Items
Set streamFile = Server.CreateObject("ADODB.Stream")
streamFile.Type = 1
streamFile.Open
StreamRequest.Position=fileItem.Start
StreamRequest.CopyTo streamFile, fileItem.Length
streamFile.SaveToFile path & fileItem.FileName, 2
streamFile.close
Set streamFile = Nothing
fileItem.Path = path & fileItem.FileName
Next
End Sub
try changing that section to this:
Code:
Public Sub Save(path)
Dim streamFile, fileItem
if Right(path, 1) <> "\" then path = path & "\"
if not uploadedYet then Upload
Dim newFileName, fs ' declare new empty variables
set fs=Server.CreateObject("Scripting.FileSystemObject") ' set 1 variable to be the file system object (which has the power to manipulate files)
For Each fileItem In UploadedFiles.Items ' loop through each file that's been uploaded when the page was submitted
newFileName = fileItem.FileName ' assign the file name to check to be this file's name
if fs.FileExists(path & newFileName) then ' use the file system object to check the current file's existence
response.write("<span class=""color:#ff0000;"">" & newFileName & " exists and could not be saved; please rename and try again.</span>") ' the file exists so through an error
else
Set streamFile = Server.CreateObject("ADODB.Stream") ' do the normal save stuff that was there before
streamFile.Type = 1
streamFile.Open
StreamRequest.Position=fileItem.Start
StreamRequest.CopyTo streamFile, fileItem.Length
streamFile.SaveToFile path & newFileName, 2
streamFile.close
Set streamFile = Nothing
fileItem.Path = path & newFileName
end if
Next
End Sub
let me know how it works for you.
Bookmarks