Create a folder with Name Files in the Application.
Design the form as follows:
<div>
<asp:FileUpload ID="flupload" runat="server" AllowMultiple="true"/>
<asp:Button ID="btnUpload" Text="Upload" runat="server" OnClick="btnUpload_Click"/>
<asp:Label ID="lblMessage" runat="server" />
</div>
.cs Page
.cs Page.
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnUpload_Click(object sender, EventArgs e)
{
foreach (HttpPostedFile postedFile in flupload.PostedFiles)
{
string fileName = Path.GetFileName(postedFile.FileName);
postedFile.SaveAs(Server.MapPath("~/Files/") + fileName);
}
lblMessage.Text = string.Format("{0} files have been uploaded successfully.", flupload.PostedFiles.Count);
}
Output:
Click on Browse Button.
After uploading you can see the files in your folder which you have created (Files). Just Refresh the Folder.
Design the form as follows:
<div>
<asp:FileUpload ID="flupload" runat="server" AllowMultiple="true"/>
<asp:Button ID="btnUpload" Text="Upload" runat="server" OnClick="btnUpload_Click"/>
<asp:Label ID="lblMessage" runat="server" />
</div>
.cs Page
.cs Page.
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnUpload_Click(object sender, EventArgs e)
{
foreach (HttpPostedFile postedFile in flupload.PostedFiles)
{
string fileName = Path.GetFileName(postedFile.FileName);
postedFile.SaveAs(Server.MapPath("~/Files/") + fileName);
}
lblMessage.Text = string.Format("{0} files have been uploaded successfully.", flupload.PostedFiles.Count);
}
Output:
Click on Browse Button.
Select the Files and Click on Upload.
After uploading you can see the files in your folder which you have created (Files). Just Refresh the Folder.
No comments:
Post a Comment
Thank you for visiting my blog