Newbie Question

  • Thread starter Thread starter James
  • Start date Start date
J

James

Hi

I have a script to upload files to a folder on the server using:

FileUpload1.SaveAs(Server.MapPath("uploads\" & FileUpload1.FileName))

If I upload into the folder and there is all ready file with the same
name then it will be overwritten.

Is there a method of preventing overwriting and returning an error or
automatically renaming the file to myfile(1).jpg

Thanks In advance

J
 
Something like this should work:

IF System.IO.File.Exists(Server.MapPath("uploads\" & FileUpload1.FileName))
THEN
'pick another name
END IF
 
Back
Top