<![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>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)