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

Similar Threads

File Upload. Root Path. 2
File upload problem 2
Upload large data 2
Uploading Files 6
Upload and dropdownlist from folder 1
Refreshing an image 9
Response.BinaryWrite HELP! 1
problem with checking FileUpload 2

Top