i try Request.Files, HttpContext.Request.Files but got no luck
html form:
<form name="" method="post" enctype="mulitipart/form-data">
<input type="file" name="file" />
</form>
i try Request.Files, HttpContext.Request.Files but got no luck
html form:
<form name="" method="post" enctype="mulitipart/form-data">
<input type="file" name="file" />
</form>
Request.Files should do it.
Scott Hanselman has a little blog post about this
foreach (string file in Request.Files)
{
HttpPostedFile hpf = Request.Files[file] as HttpPostedFile;
if (hpf.ContentLength == 0)
continue;
string savedFileName = Path.Combine(
AppDomain.CurrentDomain.BaseDirectory,
Path.GetFileName(hpf.FileName));
hpf.SaveAs(savedFileName);
}
In your question you have a typo. If that was in the final code, it would cause an issue. It's multipart/form-data
not mulitipart/form-data
.
Velio, I have my form tag coming from masterpage, so, what is the solution?