Click here to Skip to main content
14,842,195 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 asp.net c#..
and my code is for uploading is this
C#
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!!!";
           }
           else
           {
               if (Page.IsValid && FileUpload1.HasFile)
               {

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

                   if (original_image != null)
                       original_image.Dispose();
               }
           }


   }


C#
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;
help
thanks in advance!!!!!
Posted
Updated 18-May-13 23:44pm
v3
Comments
Sergey Alexandrovich Kryukov 19-May-13 22:57pm
   
In which line?
—SA

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