首先是我的代码:
<?php
public function uploadFiles($name,$gallery_code,$uncategorized = true) {
foreach($_FILES[$name]["error"] as $key=>$error) {
if(!$error) {
$photo_name = $_FILES[$name]["name"][$key];
$tmp_name = $_FILES[$name]["tmp_name"][$key];
move_uploaded_file($tmp_name,showConfigValues("img_source_admin")."/".$photo_name);
$insert = $this->_mysqli->insert("photos",array(
"id" => "",
"photos_name" => $photo_name,
"photos_description" => "",
"title_photo" => "n",
"show_description_in_photos" => "y",
"gallery_code" => $gallery_code));
if($uncategorized) {
//Resizing
$file = ''.showConfigValues("img_source_admin").'/'.$photo["photos_name"];
$src = realpath($file);
if(!list($w, $h) = getimagesize($src)) echo "Unsupported picture type!";
$picture = new Imagick(realpath(showConfigValues("img_source_admin").'/'.$photo["photos_name"]));
$picture->resizeImage(684, 457, Imagick::FILTER_LANCZOS,1);
$picture->writeImage(realpath(showConfigValues("img_source_admin").'/'.$photo["photos_name"]));
$picture->clear();
$picture->destroy();
$thumb->writeImage(showConfigValues("img_source_admin").'/'.$photo["photos_name"]);
}
}
}
}
?>
当我想上传任何图片时,调整大小不起作用,当我上传多张图片时,只有1张图片保存在数据库中。
我想保存具有相同名称的新图像(已调整大小的图像)。此调整大小的代码仅在我不上传任何图像时才起作用(代码不在同一文件中)。
感谢您的帮助