Mike Nichols - Son of Nun Technology

Quick Monorail Upload File Tip

Took me a while to track this down tonight. I thot that the HtmlHelper.Form would default to a POST method and so didn't explicitly declare it as such.  Therefore, when I did this (using Brail):

 

${HtmlHelper.Form('new.rails',{'enctype':'multipart/form-data'})}

    ${HtmlHelper.LabelFor('photo','Title:')}

    <br />

    ${HtmlHelper.InputFile('photo')}

    <br />

 

${HtmlHelper.EndForm()}

I kept getting complaints from the Controller saying it couldn't convert 'String' into an 'HttpPostedFile' object.

It turns out that I needed to include a 'method="post"' explicitly in my form helper. I'm sure its a rookie mistake but still not much info to figure it out. Now it is this:

 

 

${HtmlHelper.Form('new.rails',{'method':'post','enctype':'multipart/form-data'})}

    ${HtmlHelper.LabelFor('photo','Title:')}

    <br />

    ${HtmlHelper.InputFile('photo')}

    <br />

${HtmlHelper.EndForm()}

And it works...