- 论坛徽章:
- 0
|
我租了一个200M的空间,服务器是WINDOWS系统,装了PHP4.3.3服务器程序,支持PHP。但是我不能使用GD库,我自己的机器上也安装了类似环境,只需设置一下PHP.INI文件中的extension_dir="c:/php/extension/"参数即可。现在的情况是这样:
1.我在自己开发机器上,设置extension_dir="./" 或extension_dir="d:/mywwwroot/",将PHP.INI和php_gd2.dll拷贝到mywwwroot目录下,可以正常使用GD库。
2.租的服务器上没有支持GD库,所以我自己编辑了PHP.INI文件,按1中所设(我知道我的空间目录的绝对路径),将php.ini和php_gd2.dll一块传到我的空间的根目录下(经测试,如果你的网站程序目录下有PHP.INI配置文件,则PHP服务程序就使用此文件中的配置)。遗憾的是我不能用GD库。
所以比较困惑,因为在GD库的设置上,开发机器和服务器的设置是一样的。现在的问题是我没有办法去配置租用空间的服务器,所以我现在不能使用GD库。哪位大侠知道解决办法请告知。
程序代码如下:
<?php
dl("php_gd2.dll" ;
header ("Content-type: image/gif" ;
srand((double)microtime()*1000000);
$validate_code = strtoupper(substr(md5(rand()),rand(3,20),6));
$im = @imagecreate (69, 20)
or die ("Cannot Initialize new GD image stream" ;
$background_color = imagecolorallocate ($im, 225, 232, 232);
//设置干扰像素,防止被OCR
for ($i=0;$i<=69;$i++)
{
$point_color = imagecolorallocate ($im, rand(0,255), rand(0,80), rand(0,255));
imagesetpixel($im,rand(2,69),rand(2,20),$point_color);
}
//逐个画上验证码字符
for ($i=0;$i<=5;$i++)
{
$text_color = imagecolorallocate ($im, rand(0,255), rand(0,190), rand(0,255));
$x = 6 + $i * 10;
$y = rand(0,4);
imagechar ($im, 12, $x, $y, $validate_code{$i}, $text_color);
}
//输出PNG图像
imagepng ($im);
imagedestroy ($im);
?>;
报错如下:
Warning: dl(): Unable to load dynamic library 'd:\wwwroot\myspace\wwwroot\php_gd2.dll' - 找不到指定的程序。 in D:\wwwroot\myspace\wwwroot\test_code.php on line 2
Warning: Cannot modify header information - headers already sent by (output started at D:\wwwroot\myspace\wwwroot\test_code.php:2) in D:\wwwroot\myspace\wwwroot\test_code.php on line 3 |
|