使用secureimage溶液以生成驗證碼的代碼無法生成驗證碼的圖像,內容爲已輸出
我有CHROM控制檯上此錯誤
資源解釋爲圖像,但與MIME類型文本傳輸IM/HTML
並在此URL entring時直接用作圖片src
securimage_show.php?SID = fa5e1eb19c3a534885632e
我有此錯誤
無法生成驗證碼的圖像,內容爲已輸出。 這很可能是由於配置錯誤或PHP錯誤被送到 瀏覽
有人有想法?
注:我的作品在本地主機wampserver而不是遠程服務器
編輯於:
從驗證碼的開源代碼生成PHP錯誤代碼:
protected function output()
{
if ($this->canSendHeaders() || $this->send_headers == false) {
if ($this->send_headers) {
// only send the content-type headers if no headers have been output
// this will ease debugging on misconfigured servers where warnings
// may have been output which break the image and prevent easily viewing
// source to see the error.
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
}
switch ($this->image_type) {
case self::SI_IMAGE_JPEG:
if ($this->send_headers) header("Content-Type: image/jpeg");
imagejpeg($this->im, null, 90);
break;
case self::SI_IMAGE_GIF:
if ($this->send_headers) header("Content-Type: image/gif");
imagegif($this->im);
break;
default:
if ($this->send_headers) header("Content-Type: image/png");
imagepng($this->im);
break;
}
} else {
echo '<hr /><strong>'
.'Failed to generate captcha image, content has already been '
.'output.<br />This is most likely due to misconfiguration or '
.'a PHP error was sent to the browser.</strong>';
}
imagedestroy($this->im);
restore_error_handler();
if (!$this->no_exit) exit;
}
你能提供一些你的代碼? –
我會看到它,但它適用於本地主機,但不適用於遠程服務器 –
您忘了包含關鍵的if語句,其計算結果爲false ... – jeroen