File Upload Size Limit Sends "Cannot Find Server" error
Posted on 2006-07-19
I have a file upload control and everything works fine until I have a file larger than the limit (which is 4MB). I put the following code:
If FileUpload1.PostedFile.ContentLength < 4000000 Then
Label1.Text = "Received " & FileUpload1.FileName & " Content Type " & FileUpload1.PostedFile.ContentType & " Length " & FileUpload1.PostedFile.ContentLength
Label1.Text = "The File is too large."
But it doesn't do anything. The code above works if I set it to a lower value and upload a file that is less than 4MB.
Does anyone know how I can cancel the upload if it is more than the limit (4MB), and display an error message in my Label1.text?