[英]can't rotate the uploaded image using php
I try to rotate the uploaded image 90 degrees after uploading, I tried imagerotate()
method, but it's not working. 我尝试在上传后将上传的图像旋转90度,我尝试了
imagerotate()
方法,但它无法正常工作。
Here is my code: 这是我的代码:
$tmp = $_FILES['photoimg']['tmp_name'];
$path = "uploads/";
move_uploaded_file($tmp, $path."newfile.jpg");
$rotate = imagerotate($path."newfile.jpg", 90, 0);
imagejpeg($rotate);
imagedestroy($source);
imagedestroy($rotate);
Any help will be greately appreciated, thanks! 任何帮助将非常感谢,谢谢!
imagerotate needs a resource as first parameter not a file path. imagerotate需要资源作为第一个参数而不是文件路径。 You should get an error if you'd enable error reporting.
如果启用错误报告,则会出现错误。
error_reporting(E_ALL);
$source = imagecreatefromjpeg($path."newfile.jpg");
$rotate = imagerotate($source, 90, 0);
imagejpeg($rotate);
imagedestroy($source);
imagedestroy($rotate);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.