Newbie Question

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
 
S

Steve C. Orr [MVP, MCSD]

Something like this should work:

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top