| Here is the html code of the webpage
asp:FileUpload ID="FileUpload1" runat="server"
asp:Label ID="lblMessage" runat="server" Font-Bold="True" ForeColor="#0033CC" Visible="False"
Here is the code behind file
protected void btnUpload_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
try
{
string filePath = Server.MapPath("./") + System.IO.Path.GetFileName(FileUpload1.FileName);
FileUpload1.PostedFile.SaveAs(filePath);
lblMessage.Text = "File uploaded to " + filePath;
lblMessage.Visible = true;
}
catch (Exception ex)
{
throw ex;
}
}
} | | |