我有一个基本的基于php的文件上传脚本。我要做的是在文件上传后,如果上传的文件是一个图像mime类型,然后将其转换为pdf
附件是我使用的代码。此外,我有Imagemagick和Imagick模块安装在我的cpanel lunix基于副总裁。
if($thefileext =='jpg' || $thefileext =='png' || $thefileext =='jpeg')
{
echo "the filename is $thefile"; //echoing to make sure if statement works
$img = new Imagick("img/$thefile");
$img->setImageFormat('pdf');
$success = $img->writeImage("img/$thefile");
}我的问题是,当我尝试上传一个.jpg文件时,它上传得很好(所以我的php上传程序脚本是有效的),但是上面的Imagick代码似乎不起作用。我在脚本的实际上传功能之后调用它。有什么建议吗?
发布于 2014-06-05 22:56:30
啊,好的,我从$thefile中删除了文件扩展,现在它可以工作了,谢谢;)
https://stackoverflow.com/questions/24061909
复制相似问题