I found that Apache2 (you can also check Apache 1.5) has a way to limit this before downloading by dropping this in the .htaccess file:
LimitRequestBody 2097152
This limits it to 2 megabytes (2 * 1024 * 1024) when downloading a file (if I did my byte math correctly).
Note that when you do this, the Apache error log will generate this entry if you exceed this limit for a form post or receive a request:
Requested content-length of 4000107 is larger than the configured limit of 2097152
And it will also display this message in a web browser:
<h1>Request Entity Too Large</h1>
So, if you are making AJAX form entries with something like the Malsup jQuery Form Plugin, you can trap for an H1 response like this and show the result of the error.
By the way, the returned error number is 413. Thus, you can use the directive in the .htaccess file, for example ...
Redirect 413 413.html
... and return the result of a more elegant error.
Mike McKee Nov 21 '08 at 4:27 2008-11-21 04:27
source share