0

我正在尝试在 php.ini 中上传多个图像文件。我编辑了 php.ini 并将 upload_max_files 设置为 20000。但它一次只能上传 200 张图像。任何帮助都会得到帮助。

这是我的代码

if(isset($_FILES['files'])){ $count=0; foreach ($_FILES['files']['tmp_name'] as $key => $tmp_name){

    $target="upload/photo/";
    $target=$target.$_FILES['files']['name'][$key];
    $partphoto = substr("$target", 13, -4);
    $qq="select * from idol_student_photo where name='$partphoto'";
    $res=mysql_query($qq);
    $row=mysql_fetch_array($res);
    if(file_exists($target))
    {
    echo $_FILES['files']['name'][$key]." already exists in photo folder <br />";
    }
    else if($row['name'])
    {
    echo $partphoto." already exists database <br />";
    }
    else
    {

        if(move_uploaded_file($tmp_name, $target)){
            //$id = mysql_insert_id($con);


            mysql_query("INSERT INTO tablename VALUES ('$partphoto')");
            $count=$count+1;

        }
        }
}




            echo "<center>".$count."file uploaded</center>";
            }
4

1 回答 1

0

这可能是 PHP 的限制。所以我们真的不能帮你。然而; 大多数 PHP 系统都具有 zip 功能。因此,请检测您的客户端验证中是否有太多图片,并向用户建议使用 zip 方法。我没有测试过这段代码,但应该让你朝着正确的方向前进!

$zip = zip_open("/tmp/youruploaded.zip");
$target="upload/photo/";

if ($zip) {
    while ($zip_entry = zip_read($zip)) {


        $zipfilename = zip_entry_name($zip_entry);
        $target=$target.$zipfilename;
        $partphoto = substr("$target", 13, -4);
        $qq="select * from idol_student_photo where name='$partphoto'";
        $res=mysql_query($qq);
        $row=mysql_fetch_array($res);
        if(file_exists($target)) {
            echo $zipfilename." already exists in photo folder <br />";
        } else if($row['name']) {
            echo $zipfilename." already exists database <br />";
        } else{

        $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));

            if (file_put_contents($target, $buf)) {
                mysql_query("INSERT INTO tablename VALUES ('$partphoto')");
                $count=$count+1;
            } else {
                echo 'can\'t put picture';
            }
        }
    }
    zip_close($zip);
}

祝你好运

于 2013-10-21T11:46:46.473 回答