0

ここで見つけたスクリプトを変更して、一度にアップロードされる複数の画像を処理しました。ただし、スクリプトを実行しようとすると、エラーがスローされます。私は以前、スクリプトで一度に1つの画像のアップロードのみを許可していましたが、問題なく正常に機能しました。

これが私のコードです。

Function uploadMultiple(){
    $config = array(
        'allowed_types' => 'jpg|png|jpeg|gif',
        'upload_path' => $this->board_path,
        'overwrite' => false,
        //'file_name' => $fileName

    );
    //print_r($config);

    $this->load->library('upload');
    $errorCount = 0;
    $results = array(
        'errorsPresent' => false,
    );
    $successCount = 0;

    //for each image...try to upload.  if it fails, add it to the error list.
    //keep a list of successful uploads.
    print_r($_FILES);
    for ($i = 0; $i<count($_FILES); $i++){
        echo 'here';
        $_FILES['userfile']['name']    = $_FILES['userfile' . $i]['name'];
        $_FILES['userfile']['type']    = $_FILES['userfile' . $i]['type'];
        $_FILES['userfile']['tmp_name'] = $_FILES['userfile' . $i]['tmp_name'];
        $_FILES['userfile']['error']       = $_FILES['userfile' . $i]['error'];
        $_FILES['userfile']['size']    = $_FILES['userfile' . $i]['size'];

        $config['file_name']     = 'img_' . time() . '.png'; //inserts the unix time into the file name.
        $config['upload_path']   = $this->board_path;
        $config['allowed_types'] = 'jpg|jpeg|gif|png';
        $config['max_size']      = '0';
        $config['overwrite']     = FALSE;
        $this->upload->initialize($config);

        if ( ! $this->upload->do_upload()){
            $results['errorsPresent'] = true;
            $results['error'][$errorCount] = $this->upload->display_errors();
            $errorCount ++;

        } else {
            $data = array('upload_data' => $this->upload->data());              
            $pictureData = $this->upload->data();
            $file_location = $pictureData['full_path'];
            $file_location = substr($file_location, 18);//this should probably be dynamic...
            $file_location = $this->db->escape($file_location);
            $results['success'][$successCount] = $file_location;

            chmod($pictureData['full_path'], 777); //don't need to give it execute permissions but oh well.
            $successCount ++;       
        }

    }

    return $results;
}

これが500エラーです。

内部サーバーエラー

サーバーで内部エラーまたは構成ミスが発生し、リクエストを完了できませんでした。

サーバー管理者のwebmaster@localhostに連絡して、エラーが発生した時刻と、エラーの原因となった可能性のあるすべてのことを通知してください。

このエラーの詳細については、サーバーエラーログを参照してください。

さらに、ErrorDocumentを使用して要求を処理しようとしたときに、500内部サーバーエラーエラーが発生しました。

これは、apacheログファイルの内容です。

[2011年3月23日水曜日02:29:41][エラー][クライアント129.21.129.32]ModSecurity:コード500でアクセスが拒否されました(フェーズ4)。パターンマッチ"(?:\ b(?:(?:s(?: select list RESPONSE_BODYで有効な(?:( ?: M(?: S | y)| Postgre)SQL | O(?: racle | DBC)))| S(?: yntax error converti..."ではありません。[ファイル"/etc/apache2/conf.d/modsecurity/modsecurity_crs_50_outbound.conf"] [line "23"] [id "970003"] [msg "SQL Information Leakage"] [severity "WARNING"] [tag "LEAKAGE / ERRORS" ] [hostname "hostname.com"] [uri "/longboard/index.php/board/add"] [unique_id "TYmTVYEVgWYAAASKoIcAAAAJ"]

エラーメッセージに基づいて、modsecurityが何らかの理由でスクリプトをブロックしていると思いますが、理由はわかりません。任意の洞察をいただければ幸いです。

ありがとう

4

2 に答える 2

0

mod_securityを無効にしてみてください。.htaccessにこれを追加してください

SecFilterEngine Off
于 2011-03-23T08:23:49.743 に答える
0

最終的にデータベースエラーになりました。Mod_securityはエラーメッセージをブロックしていました。mod_securityログファイルを調べたところ、500エラーがスローされる原因となっているルールが見つかりました。次に、そのルールを使用してファイルにアクセスし、コメントアウトしました。apacheを再起動して再テストしたところ、データベースエラーが表示されました。これは開発サーバーなので、このルールをコメントアウトしたままにすることを考えています。(ただし、全世界にブロードキャストされます。Mod_securityをインストールした理由もあります。)

于 2011-03-25T02:25:20.000 に答える