0

セキュアイメージソリューションを使用してキャプチャ コードを生成する

クロムコンソールでこのエラーが発生しました

リソースはイメージとして解釈されますが、MIME タイプ text/html で転送されます

この URL に入力すると、画像 src として直接使用されます

securimage_show.php?sid=fa5e1eb19c3a534885632e

私はこのエラーがあります

キャプチャ イメージの生成に失敗しました。コンテンツは既に出力されています。これは、設定ミスが原因であるか、PHP エラーがブラウザに送信されたことが原因である可能性があります。

誰かがアイデアを持っていますか?

注:localhost wampserverでは機能しますが、リモートサーバーでは機能しません

編集:

php エラーを生成する captcha オープンソース コードからのコード:

 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;
}
4

4 に答える 4

3

クイックフィックス:

securimage.php ファイルの canSendHeaders 関数を置き換えるだけです

から

protected function canSendHeaders() {

    if (headers_sent()) {

        // output has been flushed and headers have already been sent
        return false;
    } else if (strlen((string) ob_get_contents()) > 0) {
        // headers haven't been sent, but there is data in the buffer that will break image and audio data
        return false;
    }

    return true;
}

protected function canSendHeaders() {

    ob_get_clean();

    if (headers_sent()) {

        // output has been flushed and headers have already been sent
        return false;
    } else if (strlen((string) ob_get_contents()) > 0) {
        // headers haven't been sent, but there is data in the buffer that will break image and audio data
        return false;
    }

    return true;
}
于 2014-07-11T08:25:25.890 に答える
0

今朝、私が数ヶ月前に行った開発で同じ問題がありました.

于 2013-07-23T07:13:34.170 に答える
0

このステートメントから判断すると、次のように評価されfalseます。

if ($this->canSendHeaders() || $this->send_headers == false) {

関数を呼び出す前に、既にブラウザに送信していoutputます。

その機能を使用できるようにするには、ブラウザに何も送信されていないことを確認する必要があります。<?phpタグを開く前に空の行やスペースがない、echoステートメントがないなど。

于 2012-05-23T16:37:26.780 に答える
0

キャプチャ イメージの生成に失敗しました。コンテンツは既に出力されています。これは、設定ミスが原因であるか、PHP エラーがブラウザに送信されたことが原因である可能性があります。

web.config の dll への参照が欠落していると思います

于 2012-05-23T15:55:25.613 に答える