Last active
August 29, 2015 14:19
-
-
Save putWorkDev/9e4a2f3394b88badb70e to your computer and use it in GitHub Desktop.
How to gracefully handle files that exceed PHP's `post_max_size`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if(empty($_FILES) && empty($_POST) && isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'post'){ //catch file overload error... | |
| $postMax = ini_get('post_max_size'); //grab the size limits... | |
| echo "<p style=\"color: #F00;\">\nPlease note files larger than {$postMax} will result in this error!<br>Please be advised this is not a limitation in the CMS, This is a limitation of the hosting server.<br>For various reasons they limit the max size of uploaded files, if you have access to the php ini file you can fix this by changing the post_max_size setting.<br> If you can't then please ask your host to increase the size limits, or use the FTP uploaded form</p>"; // echo out error and solutions... | |
| //addForm(); //bounce back to the just filled out form. | |
| }else{ | |
| // continue on with processing of the page... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| There is a way to catch / handle files exceeding max post size, this is my preferred on, as it tells the end user what has happened and who is at fault ;) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment