Click here to Skip to main content
15,881,880 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hii

I have asp.net image control on my page. I want to save image from image control on server.
I have already seen
Save image to a folder from an asp:Image control[^]

and

http://stackoverflow.com/questions/8374284/save-image-from-image-control-to-website-directory[^]

problem with this link is its not reading from ImageControl(asp:Image), i have to read it from ImageControl, because my image source is coming from jquery not from asp.net code, and i dont want to use jquery as i want to do some more image processing using asp.net.

Thanks in advance
Posted
Updated 7-Dec-12 0:15am
v2
Comments
choudhary.sumit 7-Dec-12 6:13am    
so what is the problem. on which event u want to do so?

 
Share this answer
 
Try this, I hope it may help you
C++
protected void btnUpload_Click(object sender, EventArgs e)
{
      string filename;
      string ImageFileName;
      if (pics.HasFile)
      {
          filename = System.IO.Path.GetFileName(pics.FileName);
          pics.SaveAs(Server.MapPath("/Galery/") + filename);
          ImageFileName = "/Galery/" + filename;
      }
      
      SqlConnection Conn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["myConnectionString"]);
      SqlCommand CatCmd = Conn.CreateCommand();
      Conn.Open();
      
      try
      {               
          CatCmd.CommandText = "insert into PhotoGaleryImage(CatagoryId,Path,UserId) values('CatagoryID','ImageFileName','userId')";
                
          CatCmd.ExecuteNonQuery();
      }
      catch (Exception) { }
      finally
      {
          if (Conn != null && Conn.State == ConnectionState.Open)
          {
              Conn.Close();
              Conn.Dispose();
          }
      }      
}

*Galary should be one of your folder included in the solution
*pics is the Fileupload control

Keep smiling :):):) happy coding:)
 
Share this answer
 
v2
Comments
sunil mali 7-Dec-12 6:26am    
Thanks for your reply,

but my trouble is i don't have file upload control in my page.
I just have one image control whose source is determined by jquery code..
i want to read file name from this image control or somehow i want to store image from image control to servers folder...
i don't know jquery i want to use csharp code for saving it.

again thanks for you reply... see if u can help me with this..

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