On Tue, Oct 1, 2019 at 6:32 AM Benjamin Morel <benjamin.mo...@gmail.com>
wrote:

> > We have https://www.php.net/manual/en/features.file-upload.errors.php but
> in general this is not so easy to make more convenient because this runs
> before your PHP code starts to run, so it is not like you can stick it in a
> try/catch.
>
> Hi Rasmus,
>
> These errors are only relevant when you have something in $_FILES, which
> is not always the case I'm afraid:
>
> - when exceeding post_max_size, $_FILES is empty
> - when exceeding max_file_uploads, you don't get entries in $_FILES past
> the nth allowed file
>
> I understand that because all of this happens before userland code is run,
> indeed it's not possible to catch it.
> I also understand that throwing a fatal error in this case would not be
> welcome, as it does not give userland code a chance to inform the user
> about the problem.
>
> What about setting a $_SERVER value in this case? For example:
>
> $_SERVER['CONFIG_LIMIT_EXCEEDED'] = 'post_max_size'
>
> This, together with empty $_POST and $_FILES if any limit is exceeded
> (including max_file_uploads), should be relatively sane behaviour IMO.
>

Perhaps a more generic $_SERVER['PHP_REQUEST_STATUS'] or something along
those lines where you'd put the error message from
https://www.php.net/manual/en/features.file-upload.errors.php as well. And
add new states for these exceeded limits that aren't caught there. It would
be nice if you just needed a single check instead of having to look for
multiple things.

-Rasmus

Reply via email to