I know how to upload with ASP.net\'s FileUpload control.
What I want to do is use this jQuery Multiple File Upload Plugin to upload multiple files.
Here is e
This jQuery plugin was giving every generated input control the exact same name attribute.
For this reason, the files were not posting.
I built my own javascript solution.
I will post a link to the code in a comment.
I revisited this and found that what I was trying to do wasn't very difficult at all. I got the the jquery multiple file upload plugin to work fine with my aspx form. I don't know why I was having so much trouble before.
1.) Include the jQuery library on the web form:
2.) Reference the multiple file plugin on the web form (Download it here):
3.) Add a file input on your web form with class="multi":
4.) Execute some code or call a method like this on form submission:
void SendMail(string from, string to, string subject, string body, string smtpServer)
{
// create mail message
MailMessage mail = new MailMessage(from, to, subject, body);
// attach posted files
for (int i = 0; i < Request.Files.Count; i++)
{
HttpPostedFile file = Request.Files[i];
mail.Attachments.Add(new Attachment(file.InputStream, file.FileName));
}
//send email
new SmtpClient(smtpServer).Send(mail);
}
This is all that I had to do to attach multiple files to an email sent from an aspx page.
If you want to increase the total size of the files that can be uploaded, add this to your web.config file:
The executionTimeout is measured in seconds and maxRequestLength is measured in kilobytes. In this example, the request will timeout after 4 minutes and will allow a 30mb request.