简体   繁体   中英

Web Api can't upload multiple files

I am using the solution by Filip W from here . For a single file, it works just fine. But for multiple files I get the error: NetworkError: 500 Internal Server Error .

Response
Cache-Control no-cache
Content-Length 0
Date Tue, 08 Apr 2014 15:23:07 GMT
Expires -1
Pragma no-cache
Server Microsoft-IIS/8.0
X-AspNet-Version 4.0.30319
X-Powered-By ASP.NET
X-SourceFiles =?UTF-8?B?YzpcdXNlcnNcYW5kcmV5LnNoZWRrb1xkb2N1bWVudHNcdmlzdWFsIHN0dWRpbyAyMDEzXFByb2plY3RzXFBSRVBQXFBSRVBQXGFwaVx1cGxvYWQ=?=
Request
Accept text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
Accept-Encoding gzip, deflate
Accept-Language en-us,en;q=0.5
Connection keep-alive
Cookie __AntiXsrfToken=b7dbaa70f0cd4c35a8a3a22d75faae03
Host localhost:4955
Referer http://localhost:4955/test.html
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20100101 Firefox/11.0

Simple html:

<body>
    <form action="/api/upload" method="post" enctype="multipart/form-data">
        <label for="somefile">File</label>
        <input name="somefile" type="file" multiple />
        <input type="submit" value="Submit" />
    </form>
</body>

How can I fix this?

The accepted answer, while correct is not the solution to this problem. In case anyone finds this while googling, I thought I'd steer you in the right direction.

Here's how to solve the problem ... Edit web.config and add a maxRequestLength to the system.web section like so:

<configuration>
  <system.web>
    <httpRuntime maxRequestLength ="2000000"/>
  </system.web>
</configuration>

This'll increase your upper limit which is really the cause of the OP's issues

If you are following this tutorial by Filip W, I think the action name has typo

Change

<form action="/api/upload"

To

<form action="/api/uploading"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM