Click here to Skip to main content
15,903,523 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
See more:
I have uploaded the image by using FileUpload control into Image Control.
and Now my I have to save the same image into already existed xml file..
And then I have to read all the Images in XMl File and display those in gridview.. Can anbody help?

What I have tried:

C#
protected void btn_Create_Click(object sender, EventArgs e)
    {
        if (FileUpload1.HasFile)
        {

            string filename = System.IO.Path.GetFileName(FileUpload1.FileName);

            FileUpload1.SaveAs(Server.MapPath("~/Images/") + filename);

            /*Uploaded file path*/

            string filePath = "Images/" + filename;
            /*Code to save the file path into data base*/
            lblDisplay.Text = "File uploaded successfully.";

            Image1.ImageUrl = filePath;

        }

        else
        {

            lblDisplay.Text = "Please select file.";

        }


I have tried like this. Till then its working fine. I don't know wt I have to do next...?
Posted
Updated 20-Apr-16 3:11am
v2
Comments
Richard Deeming 20-Apr-16 9:03am    
What's the structure and path of your XML file?
F-ES Sitecore 20-Apr-16 10:08am    
Are you looking to store the image filename in the XML, or the actual image itself?
Sergey Alexandrovich Kryukov 20-Apr-16 10:34am    
There is no such thing, as "image in XML". An element or attribute can be considered as image if some application interpret something as image. Semantic of a particular XML schema is unrelated to XML as concept.
—SA
Mohibur Rashid 20-Apr-16 21:41pm    
encoding base64 would be an idea.
Mircea Diaconescu 21-Apr-16 3:52am    
Or use SVG images, then in the XML you have a svg child, that being the image. However, Sergey has right, semantically speaking, there is no such thing as "image in XML", but only structured data...which at end can be anything as long as it can be expressed with XML and, very important, does not violate XML specification!

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