I agree, it sounds like
Anonymous Monk is looking for a solution that would best encompass both client-side and server-side routines - However, for basic upload size determination, the
CONTENT_LENGTH environment variable can be used to find the size of the
POST component of the multi-part request - This approach has merit where the server-side application may need to manipulate the uploaded file via a process where there are subsequent limits on file size. It should also be noted to that this is the same way by which
CGI.pm imposes
POST size restrictions as set by the
$CGI::POST_MAX variable.
An example as to how one can make use of the CONTENT_LENGTH environment variable to impose custom handling of over-size multi-part requests can be found here.