EDIT: I found this info here:
post_max_size
intSets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize. Generally speaking, memory_limit should be larger than
post_max_size
. When an int is used, the value is measured in bytes. Shorthand notation, as described in this FAQ, may also be used. If the size of post data is greater than post_max_size, the $_POST and $_FILES superglobals are empty. This can be tracked in various ways, e.g. by passing the $_GET variable to the script processing the data, i.e.<form action="edit.php?processed=1">
, and then checking if $_GET[âprocessedâ] is set.
In my php.ini I have memory_limit = 128M, post_max_size = 50M and upload_max_filesize = 25M
The "file too large message doesnât get displayed I think, because â$_FILES superglobals are empty.â when the file size is > post_max_size (= 50M) I was trying with a 91MB file.
If I set if ($_FILES[âmy_uploadâ][âsizeâ] > 19000000) , then if I try to upload say, 21MB, I see my error message correctly.
Only when the upload size is > post_max_size is there a problem. How to get around that?? I donât understand the tip they give.
END OF EDIT
I have a form where students can upload homework. The homework is recordings, MP3s.
I have this to check if the file is too small, works fine, goes back to the form and displays the error message:
//set a limit to the file minimum size
if ($_FILES['my_upload']['size'] < 150000)
{
$_SESSION['error'] = "é误ďźďź <br>
The file you are sending is too small. <br>
Your file should be more than 150KB. <br>
This is cannot be the homework. <br>
Please check the file you are sending and send again. <br>
Your file could not be sent. <br>";
//include "/uploadFiles20BE/uploadessays_pairs_V1.html.php";
header('Location: /uploadFiles20BE/uploadessays_pairs_V1.html.php');
exit();
}
but if I try a file which is too big, well, it doesnât get uploaded, but I donât get the error message, I see a wrong version of my success message. The correct version should show the studentsâ names and numbers and says âSuccess! You file was successfully uploadedâ Normally the files will not be more than about 8MB
//set a limit to the file upload size
if ($_FILES['my_upload']['size'] > 19000000)
{
$_SESSION['error'] = "é误ďźďź <br>
The file you are sending is too big. <br>
The maximum size should be less than 20MB <br>
Please send a smaller file or send the file in an email. <br>
Your file could not be sent. <br>";
//echo '$_FILES[\'my_upload\'][\'size\']' . $_FILES['my_upload']['size'];
//echo '<br><br>';
//echo '$_SESSION[\'error\'] is ' . $_SESSION['error'];
//include "/uploadFiles20BE/uploadessays_pairs_V1.html.php";
header('Location: /uploadFiles20BE/uploadessays_pairs_V1.html.php');
exit();
}
Any tips as to why the âtoo largeâ check is not working please?