Click here to Skip to main content
15,905,566 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to Update image in data table? Using file upload
Posted
Updated 16-Feb-14 23:30pm
v2
Comments
Ankur\m/ 17-Feb-14 5:21am    
FileUpload Control is used to UPLOAD files. File type is irrelevant (though can be configured to restrict only certain file types). It has nothing to do with UPDATING a file. What is it exactly that you want?
Sai Prasad anumolu 17-Feb-14 5:28am    
Only images files - For example i upload image in Facebook or any job portal , i decide to change my profile picture. i will change my profile picture Past image is deleted auto matically

1 solution

XML
<![CDATA[<%@ Page Language="C#" %>]]>

<script runat="server">
    protected string uploadedImgPath;
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (FileUpload1.HasFile)
        {
            uploadedImgPath = "/images/" + FileUpload1.FileName;
            FileUpload1.SaveAs(Server.MapPath(uploadedImgPath));
        }
        else
        {
            emptyupload.Text = "Choose your file";
        }
    }
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <style type="text/css">
        .auto-style1 {
            font-size: larger;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div class="auto-style1">

        Pick Your file from file upload control<br />

        <asp:fileupload id="FileUpload1" runat="server" xmlns:asp="#unknown" />
        <br />
        <br />
        <asp:button id="Button1" runat="server" onclick="Button1_Click" text="Save" xmlns:asp="#unknown" />
        <br />
        <asp:label id="emptyupload" runat="server" xmlns:asp="#unknown"></asp:label>
    </div>
    </form>
    <p>
        Your Uploaded Image</p>
        <img src="<%=uploadedImgPath%>" />
</body>
</html>



please refer all example from Google Friend..

https://www.google.co.in/search?
noj=1&q=update+new+image+from+file+upload+asp.net&oq=update+new+image+from+file+upload+as&gs_l=serp.3.0.33i21.1939.2494.0.4181.3.3.0.0.0.0.340.607.1j0j1j1.3.0....0...1c.1.35.serp..2.1.340.jHmlU5lmoWU
[^]
 
Share this answer
 
v3
Comments
Sai Prasad anumolu 17-Feb-14 5:50am    
I need Image updation
Siva Hyderabad 17-Feb-14 5:55am    
first you get img Id from the DB..like

Select Imgid from Tabname where imgid="1"
Siva Hyderabad 17-Feb-14 6:04am    
You have to take Edit button,for retrive last image from the DB?call the above query,then you can get the last update image...
when you click on edit button,then file upload control display last updated image path...
Now you choose another image file ..then you click on update button..I think it's may be your requirement
Sai Prasad anumolu 17-Feb-14 7:47am    
i got output siva thanks
Siva Hyderabad 17-Feb-14 7:49am    
fine..welcome

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