Saving a posted file

I have an HTML page with a form:

<form method="post" enctype="multipart/form-data" action="saveform.aspx">

And the form has lots of inputs that are passed along to saveform.aspx with no problem, but I’m not sure how to grab and save the posted file:

<input name="Certificate" id="Certificate" type="file">

I’m trying this but getting 0 for the count:

HttpFileCollection MyFileCollection = Request.Files;
    
Response.Write("MyFileCollection.Count: " + MyFileCollection.Count); // Returns 0
    
for (int i = 0; i < MyFileCollection.Count; i++) {
    MyFileCollection[i].SaveAs("Testing.txt");
}

Any ideas? I can grab all other form elements just fine using Request.Form[“–whatever key–”] just fine but having a tough time with files.

Thanks!

Response.Write("Request.Files.Count: " + Request.Files.Count);	if (Request.Files.Count > 0) {
		HttpPostedFile file = Request.Files[0];
		Response.Write("<br />File!");
		file.SaveAs(Server.MapPath("certs/Testing.txt"));
	}

This works in all browsers but IE. For some reason Request.Files.Count returns 0. Everything is working as expected in Chrome and Firefox.

Are you using jQuery? Add: data-ajax=“false” to the form.

No. It’s a simple HTML form whose action points to an ASPX file. The form data is being sent by all browsers, but for some reason when I use IE the file isn’t being sent.