Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image processing 使用ftp层Joomla 2.5的JImage toFile()权限_Image Processing_Joomla_Joomla2.5 - Fatal编程技术网

Image processing 使用ftp层Joomla 2.5的JImage toFile()权限

Image processing 使用ftp层Joomla 2.5的JImage toFile()权限,image-processing,joomla,joomla2.5,Image Processing,Joomla,Joomla2.5,我有一个使用JImage的缩略图上传和裁剪脚本。 它通常工作正常,但我安装在共享主机上,所以我使用Joomla ftp层来解决文件权限问题 但是,我在尝试保存到文件时遇到以下错误 '无法打开xxx/xxxx/xxx.jpg进行写入,权限被拒绝' 未保存最终处理的图像文件 这是我的密码: $thumb = new JImage($uploadPath); $sourceWidth= $thumb->getWidth(); $sourceHe

我有一个使用JImage的缩略图上传和裁剪脚本。
它通常工作正常,但我安装在共享主机上,所以我使用Joomla ftp层来解决文件权限问题

但是,我在尝试保存到文件时遇到以下错误

'无法打开xxx/xxxx/xxx.jpg进行写入,权限被拒绝'

未保存最终处理的图像文件

这是我的密码:

$thumb = new JImage($uploadPath);
             $sourceWidth= $thumb->getWidth();
             $sourceHeight = $thumb->getHeight();

            $targetWidth = $width;
            $targetHeight = $height;

            $sourceRatio = $sourceWidth / $sourceHeight;
            $targetRatio = $targetWidth / $targetHeight;

            if ( $sourceRatio < $targetRatio ) {
                $scale = $sourceWidth / $targetWidth;
            } else {
                $scale = $sourceHeight / $targetHeight;
            }

            $resizeWidth = (int)($sourceWidth / $scale);
            $resizeHeight = (int)($sourceHeight / $scale);

            $cropLeft = (int)(($resizeWidth - $targetWidth) / 2);
            $cropTop = (int)(($resizeHeight - $targetHeight) / 2);



             $thumb=$thumb->resize($resizeWidth,$resizeHeight,true);
             $thumb=$thumb->crop($width, $height,0,0,true);


            $thumbpath = JPATH_SITE.DS.'images'.DS.'tours'.DS.'thumbnails'.DS.$id.'.jpg';
            $thumb->toFile($thumbpath,'IMAGETYPE_JPG');


            JFile::delete($uploadPath);
$thumb=newjimage($uploadPath);
$sourceWidth=$thumb->getWidth();
$sourceHeight=$thumb->getHeight();
$targetWidth=$width;
$targetHeight=$height;
$sourceRatio=$sourceWidth/$sourceHeight;
$targetRatio=$targetWidth/$targetHeight;
如果($sourceRatio<$targetRatio){
$scale=$sourceWidth/$targetWidth;
}否则{
$scale=$sourceHeight/$targetHeight;
}
$resizeWidth=(int)($sourceWidth/$scale);
$resizeHeight=(int)($sourceHeight/$scale);
$cropLeft=(int)($resizeWidth-$targetWidth)/2);
$cropTop=(int)($resizeHeight-$targetHeight)/2);
$thumb=$thumb->resize($resizeWidth,$resizeHeight,true);
$thumb=$thumb->crop($width,$height,0,0,true);
$thumbpath=JPATH_SITE.DS.images.DS.tours.DS.thumbnails.DS.$id.jpg';
$thumb->toFile($thumbpath,'IMAGETYPE_JPG');
JFile::delete($uploadPath);

图像正在上载到我的临时文件夹,使用$thumb->isLoaded()我知道有一个图像加载到对象,这只是最后一个失败的文件。

您是否确保该文件夹具有755权限,并且您拥有文件夹所有权?是的,文件夹为755,我还有另一个图像上传,它只是将图像上传到文件夹而不进行任何处理,效果很好。这肯定是一个与服务器端相关的问题。我已经对你的脚本进行了彻底的测试,只做了一些路径更改,以满足我的需要,而且效果非常好。您试图处理的实际映像是否具有644权限?是的,这是一个服务器问题,因为脚本在其他系统上工作正常。图像上载到临时文件,具有644权限,加载到JIMAGE对象,但尝试将其写入文件夹不起作用-在不使用JIMAGE的情况下将图像上载到文件夹。错误消息说:“无法打开“/var/www/vhosts/xxxxx/httpdocs/images/tours/thumbnails/71.jpg以供写入:权限被拒绝”-让我困惑的是71.jpg是文件夹中尚不存在的图像的新名称。OK,我发现此主机启用了安全模式,这很可能是原因。我已联系主机将其关闭,我们将看看会发生什么。