Closed as not planned
Description
Description
The following code:
<?php
if (!empty($_POST))
echo "Done.";
else {
?><!DOCTYPE html>
<html>
<head><title>xxxx</title></head>
<body>
<form method="post" enctype="multipart/form-data">
<div>Lalalala</div>
<input type="file" multiple name="diocane[]">
<input type="hidden" name="something" value="1">
<button type="submit">Upload</button>
</form>
</body>
</html>
<?php
}
when uploading 21 files (one more than the value of max_file_uploads
), resulted in this output:
Warning: Maximum number of allowable file uploads has been exceeded in Unknown on line 0
Warning: Cannot modify header information - headers already sent in Unknown on line 0
Done.
But I expected this output instead:
Warning: Maximum number of allowable file uploads has been exceeded in Unknown on line 0
I am not attempting to set any header, and yet I get the "cannot modify header information" error. I understand that headers cannot be set because of the output that was generated because of the warning, but again, my code did not attempt to send any header.
It seems that PHP is trying to set some headers, during the startup phase (i.e. before my script gets executed), but:
- I'm not sure there's a good reason for that
- if there is, do it before you handle uploaded files, or maybe silence the "cannot modify header information" warning when you do.
- give more information in the error message so that I can at least figure out what headers failed to be sent.
PHP Version
PHP 7.4.11
Operating System
Debian 10