移动文件夹中的多个文件


move multiple files in a folder

我有一个用于上传图像的for循环。如果我要上传一张图片,那么调整图片大小的数量就应该放在一个文件夹上。但我的问题是,如果它只移动原始图像,而不是调整大小的图像。如何将调整大小的图像移动到文件夹中

move_uploaded_file($_FILES['image']['tmp_name'],'uploads/'.$_FILES['image']['name']);
for ($i=1; $i <=$resize ; $i++){
    $new = $album.$i."_".$target;
    $targetWidth = round($temp_width * $percentage);
    $targetHeight = round($temp_height * $percentage);
    $targetImage = imagecreatetruecolor($targetWidth, $targetHeight);
    $image = imagecreatefromstring(file_get_contents($target));
    imagejpeg($targetImage,$new,80);
    $temp_height = $targetHeight;
    $temp_width = $targetWidth;
}

只有原始图像被移动,而不进行图像的大小调整。但如果我将删除move_uploaded_file($_FILES['image']['tmp_name'],'uploads/'.$_FILES['image']['name']);,则所有结果都在那里,但不在文件夹

imagejpeg接受3个参数。资源图像(您刚刚通过调整大小创建的图像)、文件名(如何以及在哪里存储图像)和质量。所以你需要看看第二个参数。你称它为$new,其中包含变量$album。如果你将其设置为你想要的位置(文件夹),它应该可以正常工作。

http://php.net/manual/en/function.imagejpeg.php