Click here to Skip to main content
15,889,858 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello friends

i have struggle with to 'save the image from <asp:image tag' i have just little idea HttpWebRequest will help me but i could not be implementing this.
plz give some link or idea or sample regarding this
thanks
Posted
Updated 1-Jul-14 6:45am
Comments
Sergey Alexandrovich Kryukov 30-Jun-14 14:22pm    
What have you tried so far and what's the problem? You are right, from the client side, you can use HttpWebRequest in the image URL and copy the stream to local file one-to-one; or, simpler, you can use WebClient download...
—SA
Kishanthakur 1-Jul-14 12:41pm    
just save the image into other folder in the solution explore
the main problem is:i have generate the barcode image and display in image tag so i want to save the image every time in the particular folder that image is generated...
Sergey Alexandrovich Kryukov 1-Jul-14 13:52pm    
Downloading should be done on the initiative of the user, or with the user consent. A Web application does not have access to local systems. I don't think it will be a problem in your case.
—SA

1 solution

hear is solution of my question

C#
protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
            txtBarCodeText.Focus();

        var barcode = new Code39BarCode()
        {
            BarCodeText = "HELRE WORLD",
            BarCodeWeight = BarCodeWeight.Medium,
            Height = 100
        };

        byte[] fileContents = barcode.Generate();

        string filePath = Server.MapPath("~/barcode.gif");
        File.WriteAllBytes(filePath, fileContents);
        string filepath1 = Server.MapPath("~/barcode.gif");
        string fn= Guid.NewGuid()+filepath1.Substring(filepath1.LastIndexOf("."));
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost:1231/WebFormsDemo/barcode.gif");
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        System.Drawing.Image img = System.Drawing.Image.FromStream(response.GetResponseStream());
        //imgbar is folder name which is stored the new image

        img.Save(Server.MapPath("imgbar/")+fn);

    }
 
Share this answer
 
v2

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