Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to change the name of image everytime i upload it by Fileupload control.

i have taken one fileuploader ,textbox and a save button control.
evrytime i enter on save button the image file gets saved but by its original name
Here is my Problem
i want to change the name of the uploaded image file to the name i have entered in the textbox. How is it possible, Help!!

My Code:
C#
protected void savebtn_Click(object sender, EventArgs e)
    {


MIDL
strFileName = "~/album/" "/" + FileUpload1.FileName.ToString();
FileUpload1.PostedFile.SaveAs(Server.MapPath(strFileName ));

}
Posted

http://forums.asp.net/t/1121501.aspx[^]

I hope the above information will be helpful. If you have more concerns, please let me know.
 
Share this answer
 
Comments
Henry Minute 11-Apr-11 15:20pm    
Nice link.
Monjurul Habib 11-Apr-11 15:22pm    
thank you.
Sergey Alexandrovich Kryukov 11-Apr-11 15:48pm    
Should be quite useful, my 5.
--SA
Monjurul Habib 11-Apr-11 15:52pm    
thank you.
naveen.0nick 11-Apr-11 16:14pm    
i am new in .net + i am trying to make it in C#. it is quite hard 4 me to understand it. any links to simple renaming. only renaming and saving not displaying.
Add namespace
using System.IO;

And add this line to rename the uploaded file.

File.Move(@"~/album/", @"Your_New_File_Path\" + Text1.Text);


try this.
 
Share this answer
 
MIDL
a = Fup1.FileName.Split('.');
            fileName1 = Convert.ToString(System.DateTime.Now.Ticks) + "." + a.GetValue(1).ToString();
            FilePath = Server.MapPath(@"~\MDAFile");
            Fup1.SaveAs(FilePath + @"\" + fileName1);
            string filename = FilePath + @"\" + fileName1;
 
Share this answer
 
v2
Comments
Toniyo Jackson 12-Apr-11 9:41am    
Unchecked Ignore HTML in text checkbox

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900