这是我的代码:
foreach($_FILES as $key=>$photo){
if ($check[$key] == 'OK'){
$path = '../images/chevaux/' . $_POST['horseName'] . '_' . $horseID . '/' . $key . '.' . $file_extension;
$folder = '../images/chevaux/' . $_POST['horseName'] . '_' . $horseID;
if (!is_dir($folder))
{
mkdir($folder);
}
$filename = $photo['tmp_name'];
$percent = 4.08;
list($width, $height) = getimagesize($filename);
$newwidth = $width / $percent;
$newheight = $height / $percent;
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefromjpeg($filename, $path);
imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
imagejpeg($thumb, $path);
//....
一切正常。除了我的照片是完全黑色的。目的是通过将它们除以4.08来减小它们的宽度和高度。知道上传的图像宽度等于3264像素,高度等于2448像素。也许这太过分了?