front page:
<asp:fileupload allowmultiple="true" id="fileuploadimages" runat="server" xmlns:asp="#unknown" />
<asp:button runat="server" id="btnUpload" cssclass="btnStyle" text="Upload Image" xmlns:asp="#unknown">
OnClick="btnUpload_Click" />
<asp:label id="listofuploadedfiles" runat="server" /></asp:button>
Code Behind: to upload image
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class gallery : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnUpload_Click(object sender, EventArgs e)
{
if (fileuploadimages.HasFiles)
{
foreach (HttpPostedFile uploadedFile in fileuploadimages.PostedFiles)
{
uploadedFile.SaveAs(System.IO.Path.Combine(Server.MapPath("~/images/"),
uploadedFile.FileName));
listofuploadedfiles.Text = string.Format("updated successfully");
}
}
}
}