2

I am receiving this content length error, however I do have checks in place when user tries to upload an image by checking if it goes over a specified max-image size.

Here is my code:

    //file size of the chosen image
    $file_size = $_FILES['profile']['size'];
    //setting maximum file size
    $max_file_size = 50000;

if($file_size < $max_file_size){ 

            change_profile_image($session_user_id, $file_temp, $file_explode);
            header('Location: userprofile.php');
            exit();
} else {
            echo 'File size should be less than 50 KB';

}

So from this check I assume that if a user uploads a file size which is greator than 50 KB it should just echo 'File size should be less than 50 KB'.

Thanks guys p.s Happy Valentines Day and Happy Coding !!!! :)

dark_illusion_909099
  • 1,067
  • 2
  • 21
  • 41
  • 2
    You are checking for size after user submit picture, and the error is thrown at the beginning of the script, before check. Set `post_max_size` in php.ini to something bigger, or check image size with javascript before sending. – Aleksandar Feb 15 '16 at 00:56

0 Answers0