Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileUpload Size Limit 1

Status
Not open for further replies.

abig99

Programmer
Oct 22, 2001
53
GB
While im here may as well ask my other question.

Using the FileUpload Function, If i exceed the size specified in the config file i get an nds error, now ive read alot of posts that recommend putting an error sub into the asax file, however any redirect(response.redirect server.redirect) ive tried is ignored resulting in the same NDS error.

Any ideas peeps?
 
You can change the maximum allowed size but once you start getting over this, depending on your server, you may hit problem. Have a read of this related thread: thread855-1321612




____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Ahh yes, i just read that, thanks for the reply, however the aim is to allow uploads of 25mb.

I either want to set the .config file to 25mb so its not trying to upload massive files into memmory, or find a way to stop the user uploading files greater then this before it sends its response to the server

I could do it in javascript from what ive seen, but using the scriptingobject means having activex enabled on the client PC, which isnt the default for most users as allowing foreign parties control of your files is kinda dodgy.
My goal is to allow uploads without bogging the server down on upload refusals, ie i dont want to set the config file to 1g request length as it will then have to deal with requests of that size even though it will be refusing them.

Cheers
Hayden
 
The problem is that the server doesn't know how big the file is until it has received it all (and if it's too big for it to handle it will be too late). Hopefully the limit that you set for the maximum file size, will be of a size that the server can cope with and therefore once the file is deemed to be too big, the server can issue the error message as requested.

You only other approach, as you've noted, is to try it client side which is full of problems and doesn't 100% guarantee that the file is within the limit.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Again, thank you for the reply ca8msm.


You mention the error if the size is too big, are you referring to the dns error you get when basically it stops responding, or can we generate a custom error if the size exceeds the config file paramter? If i could make a custom error it would be fine, but as yet ive found no way to do this.
 
There are two scenarios that can happen:

1) The file is larger than the maximum file size you set but the web server is still able to store this file in memory and respond accordingly.

2) The file is larger than the maximum file size you set but the web server cannot store this file in memory and respond accordingly.

Scenario #1 will mean that you can use a custom error page and tell the user the file is too big. Scenario #2 will probably mean that your web server stops responding and you can't do much about it. There may be something you can set in IIS (or whichever web server you are using) which will stop #2 occurring. Check out the forum for your web server to see if this is possible.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
The strange thing is i have a 150mb test file im using, if i set the application level config file to 25mb, the server fails and i cant get a custom error to appear (using the asax file and the redirect, see below).

If however i increase the application level config file to 200mb, the upload works fine, meaning it had the required memory available in the first place.

Am i missing something here? do i need to do something in at the machine level?

############### Code from Asax File ##################

<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.SessionState" %>
<%@ Import Namespace="System.IO" %>

<script RunAt=server>
Sub Application_Error(ByVal sender As Object, _
ByVal e As EventArgs)
' Fires when an error occurs
' Check to see whether we came
' from the upload form
'If Path.GetFileName(Request.Path) = _
' "Upload.aspx" Then
' Get the error details
Dim appException As System.Exception = _
Server.GetLastError()
Dim checkException As HttpException = _
CType(appException, HttpException)
' Verify the expected error
'If checkException.GetHttpCode = 400 And _
'checkException.ErrorCode = -2147467259 Then
' Error 400 = bad request, user
' tried to upload a file that's too large
'Session("ImageTooLarge") = True
Server.ClearError()
' Go to the original target page
Response.Redirect(" 'End If
'End If
' For other errors, just accept the default processing
End Sub
</script>

################### Code End #########################

Note: I edited alot of that code simply to see if i could get it to do a redirect.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top