enthu
enthu

Reputation: 41

save image from fileupload

I am using fileupload control to have image on the form and that that image has to be saved on some folder in hard disk say "E:\\asp_net".

Is there any possible way to save image on disk from fileupload and if there is any other image with same name, it should be overwritten?

Upvotes: 1

Views: 10967

Answers (4)

Muhammad Akhtar
Muhammad Akhtar

Reputation: 52241

Why do you need to save the file in your machine's E drive?

Your ultimate option should be in your Application Folder. It should be like...

 FileUpload1.SaveAs(Server.MapPath("~/AppFolderName/" + FileName));

Upvotes: 5

Tim Rogers
Tim Rogers

Reputation: 21713

var filename = Path.Combine(@"E:\asp_net", myFileUploadControl.FileName);
if (File.Exists(filename))
   File.Delete(filename);
myFileUploadControl.SaveAs(filename);

Upvotes: 0

SLaks
SLaks

Reputation: 887433

You're looking for the cunningly-named SaveAs method.

Upvotes: 1

Related Questions