开发者

asp.net file upload problem

I`m using vs2008. I added a webform with the following code:

<form id="form1" runat="server">
    <div>
        <table>
            <tr>
                <td>
                    upload image:
                </td>
 开发者_运维问答               <td>
                    <asp:FileUpload ID="FUImage" runat="server" />
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                    <asp:Button ID="BtnUpload" runat="server" Text="Add" />
                </td>
            </tr>
        </table>
    </div>
    </form>

and in cs file is nothing, except default pageload handler that is empty.

I run webapplication, , choosing a jpg file to upload, clicking add new button and see internet explorer can`t show the page specified message.


.NET can limit the size of requests to the server which obviously limits the maximum size of uploadable files.

http://msdn.microsoft.com/en-us/library/e1f13641.aspx explains the appropriate web.config attribute, in particular the maxRequestLength attribtue.


Chris's answer is great but if anyone stumbles across this who is on IIS7, you'll need to add these lines instead:

<system.webServer>
  <security>
    <requestFiltering>
      <requestLimits maxAllowedContentLength=”500000000″ />
    </requestFiltering>
  </security>
<system.webServer>

This allows file uploads of up to 500 Meg. This takes effect immediately upon saving web.config. No need to restart IIS.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜