[mod_python] finding length of user file before uploading-revisit

Jorey Bump list at joreybump.com
Tue Jul 18 13:26:41 EDT 2006


Kevin Albright wrote:
> I am attempting Graham Dumpleton's solution (April 2006) to prevent 
> uploads of files that are deemed to large with the suggested handler he 
> posted (shown below).  I have the PythonFixupHandler listed before 
> mod_python.publisher as instructed in httpd.conf.  Trying this method, I 
> receive the message "upload too big" returned but only after finishing 
> the upload of the offending file (I am assuming that the Fixup handler 
> is not preventing publisher from uploading).  I appreciate any help or 
> insight others can offer.  Many thanks, Kevin

FWIW, I prefer to control this globally using Apache's LimitRequestBody 
directive in http.conf:

# limit size of uploads
# ~3MB
LimitRequestBody 3072000
# ~72K (for testing)
# LimitRequestBody 72000

This will apply to all uploads to the server, and can be used in more 
narrow contexts, if desired (virtual host, directory, .htaccess). As 
with the other method, it doesn't prevent the *browser* from uploading 
files of arbitrary size. No additional headers are added to announce 
this restriction in size (it would be too late, anyway, since the 
request has already been sent).


More information about the Mod_python mailing list