i'm using the asp.net file upload control. What i'd like to be able to do is upload the and save it on the server as a different name. Can i do this or do i need to upload first and then figure out how to rename it once it's on the server. wondering what my options are. thanks
4 Answers
FileUpload.PostedFile.SaveAs
http://msdn.microsoft.com/en-us/library/system.web.httppostedfile.saveas.aspx
Comments
You should just save the file with the required name as it is shown in the MSDN:
Comments
if (FileUpload.HasFile)
{
string Prename = "PavanKumar";
string ext = System.IO.Path.GetExtension(FileUpload.PostedFile.FileName);
disp.SaveAs(Server.MapPath("~/Admin/") + Prename +ext);
}
1 Comment
Pavankumar
Just Get the Extension and add it to the Required filename You Required and Its Done