2014-11-03 73 views
0

我试图呈现一个页面上的验证码图片如下:无法呈现在PHP(的Apache2)动态创建的图像

<img src="part/captcha_image.php?rand=<?php echo rand(); ?>" id='captchaimg' alt="captcha image"> 

图片则返回captcha_image.php有:

header('Content-Type: image/jpeg'); // defining the image type to be shown in browser widow 
imagejpeg($image); //showing the image 

并在XMPP上的Windows机器上显示没有任何问题,但在Linux上与手动apache2安装图像不呈现,并在浏览器的开发人员的工具,我看到以下错误:

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

http://localhost/app/part/captcha_image.php?rand=1653484771 Failed to load resource: net::ERR_CACHE_MISS(仅在Chrome显示)(在Chrome和Firefox所示)

我缺少什么?

+0

您正在使用chrome,对吗?请参阅:http://stackoverflow.com/questions/26408931/bizarre-error-in-chrome-developer-console-failed-to-load-resource-neterr-ca&https://code.google.com/p/铬/问题/细节?id = 424599 – wolfemm 2014-11-03 21:26:44

+0

这是正确的。我已经在Firefox上测试了我的页面,并编辑了我的问题并提供了结果(ERR_CACHE_MISS未在Firefox上显示) – Disper 2014-11-03 21:40:38

+2

您是否使用gd模块安装了php? – Cheery 2014-11-03 21:54:47

回答

1

这听起来像这个问题已经在评论中回答。对于这样的问题,一定要打开PHP配置中的详细错误报告,并直接在浏览器地址栏中点击图像的URL。

如果你这样做,其实问题是你需要gdgd丢失,那么错误页面会告诉你。

+0

谢谢你的建议!我纠正'error_reporting(-1);'函数调用打开详细报告? – Disper 2014-11-04 07:05:11

+0

是的,这就是我的意思。但我只是在我的项目开发实例中使用'php.ini'中的相应设置全局保留它。 – 2014-11-05 18:27:30