I don't suppose anyone's clued up on this? The documentation is terrible and far outdated (the best resource I could find was dated 2006).
My form:
<form action="DoCreate.rails" method="post">
${FormHelper.LabelFor("master.Name", "Name", {"class":"label"})}
${FormHelper.TextField("master.Name", {"class":"text-input full-width"})}
${FormHelper.LabelFor("masterFile", "File", {"class":"label"})}
<input type="file" id="masterFile" name="masterFile" />
<div class="edit-controls"><a href="/Master/Index.rails">Back</a> | <input type="submit" value="Create" /></div>
</form>
My controller action:
public void DoCreate(Master master, HttpPostedFile masterFile)
{
try
{
Bus.Master.Create(master);
if (masterFile != null)
{
masterFile.SaveAs(@"C:\" + masterFile.FileName);
}
RedirectToAction("Index");
}
catch (ApplicationException e)
{
PropertyBag["error"] = e.Message + "<br />" + e.StackTrace;
Create();
RenderView("Create");
}
}
I followed this guide also with no avail as it doesn't tell you what to do on the actual HTML page.
Looks like the problem is with the declaration of the form. When uploading files, you should use add another attribute to the form element:
enctype="multipart/form-data"