Reputation: 41
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
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
Reputation: 21713
var filename = Path.Combine(@"E:\asp_net", myFileUploadControl.FileName);
if (File.Exists(filename))
File.Delete(filename);
myFileUploadControl.SaveAs(filename);
Upvotes: 0
Reputation: 58444
following videos cover for your needs;
http://www.asp.net/general/videos/how-do-i-simple-file-uploads-in-aspnet
http://www.asp.net/general/videos/how-do-i-multiple-file-uploads-in-aspnet-1
http://www.asp.net/general/videos/how-do-i-multiple-file-uploads-in-aspnet-2
Upvotes: 1