Common PHP errors

Information for PHP. Hypertext Preprocessor
Post Reply
Posts: 94
Joined: Sun Mar 01, 2015 4:36 am

Common PHP errors

Post by dzcadii » Sun Mar 01, 2015 6:28 pm

Here are some common errors you may run into.

When trying to upload a large file nothing is uploaded and the browser seems to "refresh" without any error generation.

Solution (set the following two directives in the php.ini):
  • post_max_size
This is assuming you have access to the php.ini. You will have to set them to a little bit more than you are willing to allow for file upload and error check/validate the $_FILES['file_to_upload']['size'] against what you want.

Sample code:

Code: Select all

//The max in MB you are willing to allow
$max_allow = 10;
if($_FILES['file_to_upload']['size'] >= pow(1024,2) * $max_allow){
echo "Your file is too large to upload. Try something smaller!";

Post Reply