Friday, February 13, 2015

Upload multiple files using jQuery plugin


  • Refer the jquery.MultiFile.js
  • Add a ASP.Net file upload control to the page
  • Add the following code on the button click event for uploading the files

HttpFileCollection fileCollection = Request.Files;
for (int i = 0; i < fileCollection.Count; i++)
{
    HttpPostedFile uploadfile = fileCollection[i];
    string fileName = Path.GetFileName(uploadfile.FileName);
    if (uploadfile.ContentLength > 0)
    {
        uploadfile.SaveAs(Server.MapPath("~/UploadedFiles/") + fileName);
        lblMessage.Text += fileName + "Saved!!!";
    }
}

The multiple file upload plugin can be downloaded from here

No comments:

Post a Comment