I am looking for a solution to upload multiple files (click on browse button, and select multiple files using shift key).
I see several solutions that need to be upl
Set the property "AllowMultiple = true" as below. This property is available for 4.5 framework.
This will allow you to select multiple files at one time
Aspx Code:
Aspx.cs Code:
protected void btnFileUpload_Click(object sender, EventArgs e)
{
try
{
if (file_upload.HasFile && file_upload.PostedFiles.All(x => x.ContentType == "image/jpeg" && x.ContentLength < 102400))
{
foreach (var file in file_upload.PostedFiles)
{
file_upload.SaveAs(Server.MapPath("~/") + Path.GetFileName(file.FileName));
}
lblUploadStatus.Text = "File(s) uploaded successfully.";
}
else
{
lblUploadStatus.Text = "Please upload proper file.";
}
}
catch (Exception ex)
{
lblUploadStatus.Text = "Error in uploading file." + ex.Message;
}
}