以下是我的PHP代码:
require_once('phpthumb/phpthumb.class.php');
$phpThumb = new phpThumb();
$output_format = 'jpg';
$image_heights = array(141, 424, 990);
$image_widths = array(100, 300, 700);
$counter = sizeof($_FILES["img"]["tmp_name"]);
$count = 0;
$values = array();
foreach ($_FILES["img"]["tmp_name"] as $array_number => $holding_value)
{
$date = getTime();
$tmp_img_name = $_SESSION["username"]."_".$date["timestamp"]."."."jpg";
if(move_uploaded_file($holding_value, $temp."/".$tmp_img_name))
{
$phpThumb->resetObject();
$phpThumb->setSourceFilename($temp."/".$tmp_img_name);
$phpThumb->setParameter('config_output_format', $output_format);
if($count == 0)
{
$phpThumb->setParameter('h', $image_heights[$count]);
$phpThumb->setParameter('w', $image_widths[$count]);
$phpThumb->setParameter('q', 90);
$store_filename = $path1."_".$tmp_img_name;
}
if($count == 1)
{
$phpThumb->setParameter('h', $image_heights[$count]);
$phpThumb->setParameter('w', $image_widths[$count]);
$phpThumb->setParameter('q', 90);
$store_filename = $path2."_".$tmp_img_name;
}
if($count == 2)
{
$phpThumb->setParameter('h', $image_heights[$count]);
$phpThumb->setParameter('w', $image_widths[$count]);
$phpThumb->setParameter('q', 80);
$store_filename = $path3."_".$tmp_img_name;
}
if($phpThumb->GenerateThumbnail())
{
if($phpThumb->RenderToFile($store_filename))
{
$values[] = $store_filename;
// include '../../src/Cloudinary.php';
// include '../../src/Uploader.php';
// \Cloudinary::config(array
// (
// "cloud_name" => "dczebgs6w",
// "api_key" => "328212291514632",
// "api_secret" => "LvhRA-s59TZ30rPhCieTVx8LzIw"
// ));
// $cloudUpload = \Cloudinary\Uploader::upload($store_filename, array("timeout" => 120));
// if($cloudUpload)
}
else
{
//unable to write file to final destination directory - check folder permissions
$message= "Error! Please try again (render).";
}
}
else
{
$message= "Error! Please try again (generate).";
}
}
$count++;
unlink($temp."/".$tmp_img_name);
}
// print_r($values);
代码的问题在于,这一行代码的一切正常工作=> if(move_uploaded_file($holding_value, $temp."/".$tmp_img_name))
我甚至检查过图像是否正在上传,以便在目录中上传。但是,不知怎的,我无法生成thmbnails。为什么这样?
已经在每个循环和每一行检查了我的代码。 Ony临时图像已上传但缩略图未上传。
请帮我这个代码。在此先感谢_ / _
生成缩略图时没有生成缩略图/问题。