Click here to Skip to main content
12,253,335 members (53,172 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET
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 6-Dec-12 23:58pm
Edited 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?
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Try this, I hope it may help you
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 Smile | :) Smile | :) Smile | :) happy codingSmile | :)
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 7 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100