PHP上传图像表单+通过GD库调整大小.但它失败超过8mb

mar*_*zzz 0 php gd file-upload

我制作一个从POST 4图像接收的PHP脚本,而不是存储它们并创建拇指trought GD php库.问题是,只有当我每张4张4张照片(或每张4张2张或更少,实际上最多8 mb)时才能正常工作.为什么?我检查memory_limit(64mb),upload_max_filesize(25mb)和max_file_uploads(120secs)的值,​​如果我增加它们,没有任何反应.

看来POST数组完全被忽略了:我看到了这个因为我在php脚本上加了一些"echo".代码如上:

if(($_FILES['userfile1']['tmp_name']!="") or ($_FILES['userfile2']['tmp_name']!="") or ($_FILES['userfile3']['tmp_name']!="") or ($_FILES['userfile4']['tmp_name']!="")) {
    // JPG/JPEG, max 4mb each
    for($i=1; $i<=4; $i++) {
        if ($_FILES['userfile'.$i]['tmp_name']!="") {
            $path_parts=pathinfo($_FILES['userfile'.$i]['name']);
            if(((strtolower($path_parts['extension'])=='jpg') or (strtolower($path_parts['extension'])=='jpeg')) 
            && ($_FILES['userfile'.$i]['size']<=4194304)) {
            } else {
                $wrong=1;
            }
        }
    }

    if(isset($wrong)) {
        $abort=1;
        $messaggio="Errore - Formato delle foto non valido. Assicurati che il formato sia jpg/jpeg e che la foto non superi i 3 Megabyte";
    } else {
        mkdir("./articles/photos/".$articleid);
        mkdir("./articles/photos/thumbs/".$articleid);
        $sql="";
        for($i=1; $i<=4; $i++) {
            if ($_FILES['userfile'.$i]['tmp_name']!="") {
                $photoid=$articleid."-".$i;
                $uploaddir="./articles/photos/".$articleid."/";
                $userfile_tmp=$_FILES['userfile'.$i]['tmp_name'];   
                $userfile_name=$_FILES['userfile'.$i]['name'];

                $userfile_name=$photoid."@".trim(str_replace(" ", "", $_FILES['userfile'.$i]['name']));

                $path_parts=pathinfo($_FILES['userfile'.$i]['name']);
                $photoondb=$photoid.".".strtolower($path_parts['extension']);
                move_uploaded_file($userfile_tmp, $uploaddir.$photoondb);

                // thumbs
                $name_new_image="./articles/photos/thumbs/".$articleid."/".$photoondb;
                $file = "./articles/photos/".$articleid."/".$photoondb;

                list($actualw, $actualh, $type, $attr) = getimagesize($file);
                if(($actualw>100) or ($actualh>100)) {
                    if($actualw>$actualh) {
                        $v1=$actualw/100;
                        $width=$actualw/$v1;
                        $height=$actualh/$v1;
                    } else {
                        $v1=$actualh/100;
                        $width=$actualw/$v1;
                        $height=$actualh/$v1;
                    }
                }
                $qualita=70;
                $new_image=imagecreatetruecolor($width, $height);
                $src_image=imagecreatefromjpeg($file);
                imagecopyresampled($new_image, $src_image, 0, 0, 0, 0, $width, $height, imagesx($src_image), imagesy($src_image));
                imagejpeg($new_image, $name_new_image, $qualita);

                imagedestroy($new_image);
                imagedestroy($src_image);

                if($sql!="") $sql.=", ";
                $sql.="('$articleid', '$photoondb')";
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我希望你能理解我的意思,或多或少:)

Ser*_*min 6

你错过了另一个参数:post_max_size.它的默认值是8M ......