dongsanhu4784 2015-07-07 14:20
浏览 50

javascript php上传图片请求实体太大了

I have php javascript images upload problem. When I upload about 20kb, it is OK. But when I upload over 500kb, it fails and displays the error shown below. My web site is hosted on godaddy. In my local development computer it works and runs smoothly. Do you have any ideas??

I have tried:

ini_set('post_max_size',52428800); // 50 MB

ini_set('upload_max_filesize',52428800) // 50 MB But does not work.

//------ERROR on Web Pag----------

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.

//------------My code----------------------//

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;
            }
        }       
    } 
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何用python向钉钉机器人发送可以放大的图片?
    • ¥15 vue3加ant-design-vue无法渲染出页面
    • ¥15 matlab(相关搜索:紧聚焦)
    • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
    • ¥15 路易威登官网 里边的参数逆向
    • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
    • ¥50 需求一个up主付费课程
    • ¥20 模型在y分布之外的数据上预测能力不好如何解决
    • ¥15 processing提取音乐节奏
    • ¥15 gg加速器加速游戏时,提示不是x86架构