1
我剛將一個站點移動到運行PHP 7的新服務器上。我相信它最初是在PHP 5.4上。下面的網址應該與它的代碼顯示圖像,就像一個驗證碼:PHP動態圖像顯示不正確
http://appreviewhelper.com/static/captcha/GkK9yEiaw6
當該URL被擊中,下面的代碼爲然:
$code=rand(1000,9999);
$code = (string)$code;
$_SESSION["code"]=$code;
$im = imagecreate(50, 24);
$bg = imagecolorallocate($im, 238, 238, 238); //background color blue
$fg = imagecolorallocate($im, 85, 85, 85);//text color white
imagefill($im, 0, 0, $bg);
imagestring($im, 5, 5, 5, $code, $fg);
header("Cache-Control: no-cache, must-revalidate");
header('Content-type: image/png');
header("Content-Disposition: inline; filename=captcha.png");
imagepng($im);
imagedestroy($im);
exit();
這是工作罰款舊的服務器。我已經確定安裝了PHP GD庫並且已經啓用了該模塊,並且我已經驗證了一遍又一遍......但是,我仍然只是得到一個小的空白圖像。有任何想法嗎?
感謝
編輯:下面是gd_info輸出()從該網站:
array(12) {
["GD Version"]=>
string(5) "2.1.1"
["FreeType Support"]=>
bool(true)
["FreeType Linkage"]=>
string(13) "with freetype"
["GIF Read Support"]=>
bool(true)
["GIF Create Support"]=>
bool(true)
["JPEG Support"]=>
bool(true)
["PNG Support"]=>
bool(true)
["WBMP Support"]=>
bool(true)
["XPM Support"]=>
bool(true)
["XBM Support"]=>
bool(true)
["WebP Support"]=>
bool(true)
["JIS-mapped Japanese Font Support"]=>
bool(false)
}
似乎爲我工作,我正在運行php 7.1.1。我用裏面的代碼得到一個小圖片。錯誤日誌說什麼? – xlordt
它似乎也適用於我,並運行7.1。 例如:[鏈接](http://i66.tinypic.com/1984i_th.png) –
它也適用於php 5.4 .. –