PHP imagejpeg()问题 [英] PHP imagejpeg() problems

查看:230
本文介绍了PHP imagejpeg()问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可以在我的小型共享主机上使用的图像上传脚本,但是当我切换到Virt Ded时,它立即停止了工作.经过一番研究,我确定罪魁祸首是PHP函数imagejpeg()-这是脚本中的最后一部分代码.

I had an image upload script that worked on my little shared hosting, but just as I switched to Virt Ded, it immediately stopped working. After some research I determined the culprit to be the PHP function imagejpeg() - which was the last bit of code in the script.

它允许我将null指定为文件路径(在这种情况下,它将打印到屏幕上),但是不允许我输入任何文件路径而不返回false.

It allows me to specify null as the filepath (in which case it prints it to the screen), but does not allow me to enter ANY filepath without return false.

有人知道发生了什么事吗?

Anybody know what is going on?

推荐答案

首先,我将了解PHP安装中是否包含imagejpeg()所需的所有libgd内容.

First I would see if the PHP install contains all the libgd stuff you need for imagejpeg().

您可以像这样检查:

$extensions = get_loaded_extensions();

if( !in_array( 'gd', $extensions ) )
{
  die "libgd is not loaded";
}

如果这样做很好,您可以执行以下操作:

If that's good to go you can do something like:

$gd = gd_info();

while( list( $k, $v ) = each( $gd ) )
{
  echo "$k: $v";
}

请确保您列出了一些jpeg内容,如果没有,则需要安装一些依赖库.

Make sure you see some jpeg stuff listed, if there is none you need some dependent libraries installed.

这篇关于PHP imagejpeg()问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆