Hi All,
Need help again here
I'm using freeaspupload, and i modified a bit on renaming the file i've uploaded. The problem is if i upload the same filename, it gives me error like this :
Microsoft VBScript runtime (0x800A003A)
File already exists
/web/ltl2009hostv4ok/www/corporate/upload.asp, line 181
I tried to put this code :
Does anyone can help? thank you in advance =)Code:for each fileKey in Upload.UploadedFiles.keys 'SaveFiles = SaveFiles & Upload.UploadedFiles(fileKey).FileName & " (" & Upload.UploadedFiles(fileKey).Length & "B)" strFileType = Left(Upload.UploadedFiles(fileKey).ContentType,5) if strFileType = "image" or strFileType="appli" Then 'SaveFiles = SaveFiles & Upload.UploadedFiles(fileKey).FileName & " (" & Upload.UploadedFiles(fileKey).Length & "B) " strFileName=Upload.UploadedFiles(fileKey).FileName if inStr(strFileName,".jpg") or inStr(strFileName,".doc") or inStr(strFileName,".pdf") or inStr(strFileName,".docx") then if not Upload.UploadedFiles(fileKey).Length>1000000 then directory=uploadsDirVar & Upload.UploadedFiles(fileKey).FileName '=====modified - start rename file===== set fso = CreateObject("Scripting.FileSystemObject") set file = fso.GetFile(directory) file.name = session.Contents("ID") &"-"& strFileName '=====start check if file exist=====' Dim objFSO, strFileNameUp strFileNameUp = directory Set objFSO = Server.CreateObject("Scripting.FileSystemObject") If objFSO.FileExists (strFileNameUp) Then DelFile = DelFile & strFileNameUp & "," SaveFiles = "File is exist" Else SaveFiles = "File does not exist" End If '=====endcheck if file exist=====' myImageArray(counter) = file.name counter = counter + 1 set file = nothing set fso = nothing '=====modified - end rename file====== else DelFile = DelFile & Upload.UploadedFiles(fileKey).FileName & "," SaveFiles = "File is too large, please attach smaller size" end if else DelFile = DelFile & Upload.UploadedFiles(fileKey).FileName & "," SaveFiles = "Invalid File Name, please attach the correct one" end if else DelFile = DelFile & Upload.UploadedFiles(fileKey).FileName & "," SaveFiles = "Invalid File Type, please attach the correct one" end if next



LinkBack URL
About LinkBacks

Reply With Quote

Bookmarks