views:

62

answers:

1

I can see there are plenty of questions and resources about this but I just cant seem to see what I am doing wrong.

HTML Snippet

<form method="post" action="<%=Url.Action("Create", "Image") %>" enctype="mulitipart/form-data">
<input type="file" name="ImageFile" id="ImageFile" />

And here is the Controller code, none of the Console.Writeline lines get hit:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(Image image, HttpPostedFileBase file)
{

    if (file != null)
    {
        Console.WriteLine(file.FileName);
    }

    if (Request.Files.Count > 0)
    {
        Console.WriteLine("oh hai");
    }

What am I doing wrong?

+6  A: 

If you've copied and pasted your HTML, you have a typo in the enctype.

enctype="mulitipart/form-data"

to

enctype="multipart/form-data"
womp
Funny, the top related question has the same problem: http://stackoverflow.com/questions/375208/asp-net-mvc-how-access-file-upload-in-controller-action
rmacfie
I hate programming, thanks
qui