我在摆弄 PHP,我已经做了很长时间了,我真的不明白我在这里做错了什么..
谁能帮我,告诉我为什么转换后的图像没有保存,而上传的文件保存得很好(顺便说一句,没有被删除)?
$destination_path = getcwd().DIRECTORY_SEPARATOR."img".DIRECTORY_SEPARATOR."blog".DIRECTORY_SEPARATOR."uploads".DIRECTORY_SEPARATOR;
$result = 0;
$ext = pathinfo($_FILES['image']['name'], PATHINFO_EXTENSION);
$target_path = $destination_path . $this->input->post("postId") . ".";
if(move_uploaded_file($_FILES['image']['tmp_name'], $target_path . $ext)) {
switch ($ext) {
case ".jpg": case ".jpeg":
$image = imagecreatefromjpeg($target_path . $ext);
imagepng($image, $target_path . "png");
imagedestroy($image);
break;
case "gif":
$image = imagecreatefromgif($target_path . $ext);
imagepng($image, $target_path . "png");
imagedestroy($image);
break;
default:
break;
}
$result = 1;
}