Upload a file MVC 4 Web API .NET 4

后端 未结 1 1311
走了就别回头了
走了就别回头了 2021-01-02 12:13

I\'m using the version of MVC that shipped with Visual Studio 2012 express. (Microsoft.AspNet.Mvc.4.0.20710.0)

I assume this is RTM version.

I\'ve found p

相关标签:
1条回答
  • 2021-01-02 12:39

    You are missing a name attribute on your file input.

    <form name="uploadForm" method="post" enctype="multipart/form-data" action="api/upload" >
        <input name="myFile" type="file" />
        <input type="submit" value="Upload" />
    </form>
    

    Inputs without it will not get submitted by the browser. So your formdata is empty resulting in IsFaulted being asserted.

    0 讨论(0)
提交回复
热议问题