0

Is there a better way to do this ?

If FileUpload1.PostedFile.ContentLength > 500000 Then
    Label1.ForeColor = System.Drawing.Color.Red
    Label1.Text = "Please enter a filesize less than 500kb!"
End If
Andrey Korneyev
  • 26,353
  • 15
  • 70
  • 71
djquest
  • 31
  • 9

1 Answers1

0

I think IIS 7 uses maxAllowedContentLength for specifying file upload size (KB). Edit your web.config like so:

<system.web>
    <httpRuntime maxRequestLength="2097152" />
</system.web>
<system.webServer>
    <security>
        <requestFiltering>
            <requestLimits maxAllowedContentLength="2147483648" />
        </requestFiltering>
    </security>
</system.webServer>
scott_lotus
  • 3,171
  • 22
  • 51
  • 69