我正在尝试在php.i中上传多个图像文件,编辑了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>";
}
答案 0 :(得分: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);
}
祝你好运