Click here to Skip to main content
15,799,257 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi !!!
I am making a image upload form in c#..
and my code is for uploading is this
protected void btnupld_Click1(object sender, EventArgs e)

           if (ListBox1.SelectedItem == null)
               //lblmess.ForeColor = Color.Red;
               //lblmess.Text = "please select Image name to upload from box!!!";
               if (Page.IsValid && FileUpload1.HasFile)

                   string tmpname = ListBox1.SelectedItem.ToString();
                   ListBox1.Items.Insert(ListBox1.Items.IndexOf(ListBox1.SelectedItem), tmpname);
                   Bitmap original_image = new Bitmap(FileUpload1.FileContent);
                   waterMarkImage(original_image, tmpname);

                   if (original_image != null)


protected void uploadmethod(Bitmap imgBmp, string tmpName)
           string newName = System.IO.Path.ChangeExtension(tmpName,"gif");
           imgBmp.Save(MapPath("~/add/" + newName));
           Image1.ImageUrl = "~/add/" + newName;



here i changing the image extension and upload image on folder
this code is work in local machin is fine but when i upload on server i am face this error

System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
string newName = System.IO.Path.ChangeExtension(tmpName,"gif");
string nameBy = System.IO.Path.GetFileNameWithoutExtension(newName);
imgBmp.Save(MapPath("~/add/" + nameBy + Path.GetExtension(newName)));
Image1.ImageUrl = "~/add/" + newName;
thanks in advance!!!!!
Updated 19-May-13 0:44am
Sergey Alexandrovich Kryukov 19-May-13 22:57pm    
In which line?

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