0

I have written the php upload image files to php server. When small images within 100kB, it is success. But when over 500KB, it is failed and said no data received on server. I also do not know why. No file saved in php server of this uploading. Do you know how to solve??

function uploadImages($input, $file)
{

    if($input == null || $input == "")
    {
        return false;
    }
    $stringVal = $input; 
    $value  = str_replace('data:image/png;base64,', '', $stringVal);

    if ($this->check_base64_image($value) == false) {
        return false;
    }

    $actualFile  = base64_decode($value);
    $img = imagecreatefromstring($actualFile);
    $imgSize = getimagesize('data://application/octet-stream;base64,' . base64_encode($actualFile));


    if ($img == false) {
        return false;
    }else
    {

        /*** maximum filesize allowed in bytes ***/
        $max_file_length  = 100000;

        log_message('debug', 'PRE UPLOADING!!!!!!!!');

        if (isset($img)){

            log_message('debug', 'UPLOADING!!!!!!!!');

            // check the file is less than the maximum file size
            if($imgSize['0'] > $max_file_length || $imgSize['1'] > $max_file_length)
            {
                log_message('debug', 'size!!!!!!!!'.print_r($imgSize));
                $messages = "File size exceeds $max_file_size limit";
                return false;
            }else if (file_exists($file)) {
                return false;
            }else
            {
                file_put_contents($file, $actualFile);
                return true;
            }
        }       
    } 
}
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 3
    Possible duplicate? http://stackoverflow.com/questions/2184513/php-change-the-maximum-upload-file-size – GluePear Jul 04 '15 at 08:51
  • Out of security reasons php uses a size limit. You can change that statically or dynamically. Without you changing that the default is used which may explain your issues. – arkascha Jul 04 '15 at 08:57

1 Answers1

0

try this,

ini_set('post_max_size',52428800); // 50 MB
ini_set('upload_max_filesize',52428800) // 50 MB
Kiran LM
  • 1,359
  • 1
  • 16
  • 29
  • It says: Request Entity Too Large The requested resource /index.php/newPost/ does not allow request data with GET requests, or the amount of data provided in the request exceeds the capacity limit. Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request. – Wing Hing Raymond Chiu Jul 05 '15 at 06:05