1

画像アップローダーで、アップロードされた画像が特定のサイズを超えた場合にエラー メッセージを表示するように設定しています。ただし、非常に大きなものをアップロードすると、エラー メッセージがバイパスされ、ユーザーに見せたくない POST Content-Length exceeded エラー メッセージが表示されてスタックします。画像ファイルが大きすぎるとエラー メッセージが表示されない理由を誰か教えてください。

写真がアップロードされたときに呼び出される検証関数は次のとおりです。

//------------------------------
private function _verify($fn) {
//------------------------------
    global $_WEBCONFIG;

    $isValid = TRUE;
    $userID = isset($_POST["hidId"]) ? (int)$_POST["hidId"] : 0;
    $this->record2->p_id = $this->proId;

    $fieldName  = "txtName";
    $fieldValue = SanitizeData($_POST[$fieldName]);
    if (!$fieldValue || strlen($fieldValue = trim($fieldValue)) == 0) {
        $this->record2->i_name = '';
    } else {
        $this->record2->i_name = $fieldValue;
    }

    $fieldName  = "fleImage";
    if (isset($_FILES[$fieldName]) && strlen($_FILES[$fieldName]['name']) > 0) {
        $fieldValue = $_FILES[$fieldName]['name'];
        $file_ext   = strtolower(GetExtName($fieldValue));
        $arExts     = explode(",", VALID_IMGS);

        if (!in_array($file_ext, $arExts)) {
            $this->errors[] = "Invalid Image Format. (Allowed image types: " . VALID_IMGS . ")";
            $isValid = FALSE;
        } else {
            $size = getimagesize($_FILES[$fieldName]['tmp_name']);
             if ($size[0] < $_WEBCONFIG['THUMB_WIDTH'] || $size[1] < $_WEBCONFIG['THUMB_HEIGHT']) {
                $this->errors[] = "Invalid Image Size. (Image Dimensions: " . $_WEBCONFIG['IMAGE_WIDTH'] . " x " . $_WEBCONFIG['IMAGE_HEIGHT'] . " or larger)";
                $isValid = FALSE;
             }

             $imageSize = filesize($_FILES[$fieldName]['tmp_name']);
             if ($imageSize > 16777216){
                $this->errors[] = "Invalid File Size. File size must be smaller than 128 MB.";
                $isValid = FALSE;
             }

        }
    } else if ($fn == 0) {
        $this->errors[] = "Please upload an Image (Image Dimensions: " . $_WEBCONFIG['IMAGE_WIDTH'] . " x " . $_WEBCONFIG['IMAGE_HEIGHT'] . " or larger.)";
        $isValid = FALSE;
    }

    $fieldName  = "txtOrder";
    $fieldValue = SanitizeData($_POST[$fieldName]);
    if (strlen($fieldValue = trim($fieldValue)) == 0) {
        $this->record2->i_sort_id = 99999;
    } else {
        $this->record2->i_sort_id = $fieldValue;
    }

    return $isValid;
}//end function

エラー メッセージをバイパスしてアップロードしている画像のサイズは 37.4 MB です

4

1 に答える 1