I was having the same problem. I don't know why, but the problem arises when iterating over the context.Request.Files collection with a foreach
loop.
Instead, use a traditional for
loop and explicitly cast to an HttpPostedFile instead.
HttpFileCollection files = context.Request.Files;
for (int i = 0; i < files.Count;i++ )
{
HttpPostedFile file = files[i];
string fname = context.Server.MapPath("~/uploads/" + file.FileName);
file.SaveAs(fname);
}
Source: http://www.binaryintellect.net/articles/f2a2f1ee-e18a-416b-893e-883c800f83f4.aspx