I have a field of type image in my database which is mapped as binary in my model (ADO.NET Entity Framework).
But somehow the image that I get from the input file box is not being passed to the object. I know this because I debuged my action and the object Language (the image I trying to upload to the database is a flag) has the property Flag set to null and that is very bad! It should contain the image uploaded. Do I have to do something else?
Below is my form html code and my action code:
<% using (Html.BeginForm("Create", "Language", FormMethod.Post, 
          new {enctype="multipart/form-data"})) {%>
    <fieldset>
        <legend>Fields</legend>
        <p>
            <label for="Id">Id:</label>
            <%= Html.TextBox("Id") %>
            <%= Html.ValidationMessage("Id", "*") %>
        </p>
        <p>
            <label for="Name">Name:</label>
            <%= Html.TextBox("Name") %>
            <%= Html.ValidationMessage("Name", "*") %>
        </p>
        <p>
            <label for="Flag">Flag:</label>
            <!--
            File box is a helper that I got from this link:
            http://pupeno.com/blog/file-input-type-for-forms-in-for-asp-net-mvc/
            -->
            <%= Html.FileBox("Flag")  %>
            <%= Html.ValidationMessage("Flag", "*") %>
        </p>
        <p>
            <label for="IsDefault">IsDefault:</label>
            <%= Html.TextBox("IsDefault") %>
            <%= Html.ValidationMessage("IsDefault", "*") %>
        </p>
        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
<% } %>
I am using Visual Studio 2008.
[AcceptVerbs(HttpVerbs.Post)]  
public ActionResult Create(Language language)  
{  
    // Here language.Flag is null. Shouldn't the Flag property be a
    // binary field ready to be stored in the database along with the others?
    if (!ModelState.IsValid || !_service.CreateLanguage(language))  
    {  
        return View("Create", language);  
    }  
    return RedirectToAction("Index");  
}  
What am I doing wrong?