Почему отправка формы с 5 МБ файлом не работает, однако она работает с 4 МБ в php yii framework? - PullRequest
0 голосов
/ 09 июня 2018

Надеюсь, все в порядке.

Я разработчик ASP.Net, однако сейчас я использую php yii framework.

У меня есть форма, в которой я могу прикрепить к ней файлы.

При отправке формы я провожу проверку адреса электронной почты и имени.

Я использую этот метод $ this-> validateInput ($ _ POST ['FullName']);

Когда я присоединяю файл 5 МБ к форме, проверка не работает.

$fullName = $this->validateInput($_POST['FullName']);
                if (!$fullName || $fullName == "") {
                    return "ssv_fullname";
                }

Он возвращает мне ssv_fullname.

Однако, когда я присоединяю менее 5 МБ, все идет хорошо, и форма отправляется.

вот мой метод проверки:

private function validateLoanApplication() {
       // $valid = true;
        if (isset($_POST["user_answer"]) && substr(md5($_POST["user_answer"]), 5, 10) === $_SESSION['edbcaptchaans']) 
        {
           $valid = true;
        }
        else 
        {
          $valid = false;
          return "Incorrect Verification Code";
        }
        if($valid)
        {
                $fullName = $this->validateInput($_POST['FullName']);
                if (!$fullName || $fullName == "") {
                    return "ssv_fullname";
                }

                $dob = $this->validateInput($_POST['dob']);
                if (isset($_POST['dob'])) {
                    $dob = $this->validateInput($_POST['dob']);
                    if (!$dob || $dob == "") {
                       return "ssv_dob";
                    }
                }

                if (isset($_POST['Salary'])) {
                    $Salary = $this->validateInput($_POST['Salary']);
                    if (!$Salary || $Salary == "") {
                        return "ssv_salary";
                    }
                }

                if (isset($_POST['employer'])) {
                    $employer = $this->validateInput($_POST['employer']);
                    if (!$employer || $employer == "") {
                       return "ssv_employer";
                    }
                }

                if (isset($_POST['mobile'])) {
                    $mobile = $this->validateInput($_POST['mobile']);
                    if (!$mobile || $mobile == "") {
                       return "ssv_mobile";
                    }
                }

                // if (isset($_post['email']) && $_post['email'] != "") {
                    // $email = $this->validateinput($_post['email']);
                // } else {
                   // return "ssv_email";
                // }

                 if (isset($_POST['workadrress']) && $_POST['workadrress'] != "") {
                    $workadrress = $this->validateInput($_POST['workadrress']);
                } else {
                    return "ssv_work_address";
                }

                if(isset($_POST['loanamount'])){
                    $loanamount = $this->validateInput($_POST['loanamount']);
                    if (!$loanamount || $loanamount == "") {
                       return "ssv_loan_amount";
                    }
                } else {
                      return "ssv_loan_amount";
                }

                $loantype = $_POST['loantype'];

                // if (isset($_POST['loantype'])) {
                    // $loantype = $this->validateInput($_POST['loantype']);
                    // if (!$loantype || $loantype == "") {
                        // return "ssv_type_of_loan";
                    // }else {
                      // return "ssv_loan_amount Test Instead of loan type";
                    // }

                // }

                if (isset($_POST['id_name'])) {
                    $id_name = $this->validateInput($_POST['id_name']);
                    if (!$id_name || $id_name == "") {
                        return "ssv_identifier_1";
                    }
                }

                if (isset($_POST['id_mobile'])) {
                    $id_mobile = $this->validateInput($_POST['id_mobile']);
                    if (!$id_mobile || $id_mobile == "") {
                         return "ssv_identifier_mobile_1";
                    }
                }

                if (isset($_POST['id_relation'])) {
                    $id_relation = $this->validateInput($_POST['id_relation']);
                    if (!$id_relation || $id_relation == "") {
                        return "ssv_identifier_relation_1";
                    }
                }

                if (isset($_POST['id2_name'])) {
                    $id2_name = $this->validateInput($_POST['id2_name']);
                    if (!$id2_name || $id2_name == "") {
                        return "ssv_identifier_2";
                    }
                }

                if (isset($_POST['id2_mobile'])) {
                    $id2_mobile = $this->validateInput($_POST['id2_mobile']);
                    if (!$id2_mobile || $id2_mobile == "") {
                        return "ssv_identifier_mobile_2";
                    }
                }

                if (isset($_POST['id2_relation'])) {
                    $id2_relation = $this->validateInput($_POST['id2_relation']);
                    if (!$id2_relation || $id2_relation == "") {
                       return "ssv_identifier_relation_2";
                    }
                }

                $id3_name = $this->validateInput($_POST['id3_name']);
                $id3_mobile= $this->validateInput($_POST['id3_mobile']);
                $id3_relation = $this->validateInput($_POST['id3_relation']);

                if (isset($_POST['houseno'])) {
                    $house_no = $this->validateInput($_POST['houseno']);
                    if (!$house_no || $house_no == "") {
                       return "ssv_house_number";
                    }
                }

                if (isset($_POST['street'])) {
                    $street = $this->validateInput($_POST['street']);
                    if (!$street || $street == "") {
                      return "ssv_street";
                    }
                }

                if (isset($_POST['area'])) {
                    $area = $this->validateInput($_POST['area']);
                    if (!$area || $area == "") {
                       return "ssv_area";
                    }
                }

                if (isset($_POST['Emirate'])) {
                    $emirate = $this->validateInput($_POST['Emirate']);
                    if (!$emirate || $emirate == "") {
                       return "ssv_emirate";
                    }
                }

                $district = $this->validateInput($_POST['district']);
                $city = $this->validateInput($_POST['city']);
                // Changed on 23-05-2018 by mohammad jouhari to increase the size of attachment file to 5 mb
                if ($_FILES['doc1']!='') {
                     if($_FILES['doc1']['size']<=7242880) {
                        $fileParts= explode('.', $_FILES['doc1']['name']);
                        $imgext1=strtolower( end($fileParts) );
                        if($imgext1!='tiff' && $imgext1!='pdf' && $imgext1!='jpg' && $imgext1!='jpeg' && $imgext1!='tif') {
                            return "ssv_valid_extensions";
                        }
                    } else {
                        return "ssv_valid_size_2";
                    }
                } else {
                    return "ssv_valid_required";
                }

                if ($_FILES['doc2']!='') {
                    if($_FILES['doc2']['size']<=7242880) {
                        $fileParts= explode('.', $_FILES['doc2']['name']);
                        $imgext1=strtolower( end($fileParts) );
                        if($imgext1!='tiff' && $imgext1!='pdf' && $imgext1!='jpg' && $imgext1!='jpeg' && $imgext1!='tif') {
                            return "ssv_valid_extensions";
                        }
                    } else {
                        return "ssv_valid_size_2";
                    }
                } else {
                    return "ssv_valid_required";
                }

                if ($_FILES['doc3']!='') {
                    if($_FILES['doc3']['size']<=7242880) {
                        $fileParts= explode('.', $_FILES['doc3']['name']);
                        $imgext1=strtolower( end($fileParts) );
                        if($imgext1!='tiff' && $imgext1!='pdf' && $imgext1!='jpg' && $imgext1!='jpeg' && $imgext1!='tif') {
                            return "ssv_valid_extensions";
                        }
                    } else {
                        return "ssv_valid_size_2";
                    }
                } else {
                    return "ssv_valid_required";
                }

                if ($_FILES['doc4']!='') {
                    if($_FILES['doc4']['size']<=7242880) {
                        $fileParts= explode('.', $_FILES['doc4']['name']);
                        $imgext1=strtolower( end($fileParts) );
                        if($imgext1!='tiff' && $imgext1!='pdf' && $imgext1!='jpg' && $imgext1!='jpeg' && $imgext1!='tif') {
                            return "ssv_valid_extensions";
                        }
                    } else {
                        return "ssv_valid_size_2";
                    }
                } else {
                    return "ssv_valid_required";
                }

                if ($_FILES['doc5']!='') {
                    if($_FILES['doc5']['size']<=7242880) {
                        $fileParts= explode('.', $_FILES['doc5']['name']);
                        $imgext1=strtolower( end($fileParts));
                        if ($imgext1!='tiff' && $imgext1!='pdf' && $imgext1!='jpg' && $imgext1!='jpeg' && $imgext1!='tif') {
                            return "ssv_valid_extensions";
                        }
                    } else {
                        return "ssv_valid_size_2";
                    }
                } else {
                    return "ssv_valid_required";
                }

                if ($_FILES['doc6']!='') {
                    if($_FILES['doc6']['size']<=7242880) {
                        $fileParts= explode('.', $_FILES['doc6']['name']);
                        $imgext1=strtolower( end($fileParts));
                        if($imgext1!='tiff' && $imgext1!='pdf' && $imgext1!='jpg' && $imgext1!='jpeg' && $imgext1!='tif') {
                            return "ssv_valid_extensions";
                        }
                    } else {
                        return "ssv_valid_size_2";
                    }
                } else {
                    return "ssv_valid_required";
                }

                if ($_FILES['doc7']!='') {
                    if ($_FILES['doc7']['size']<=7242880) {
                        $fileParts= explode('.', $_FILES['doc7']['name']);
                        $imgext1=strtolower( end($fileParts) );
                        if($imgext1!='tiff' && $imgext1!='pdf' && $imgext1!='jpg' && $imgext1!='jpeg' && $imgext1!='tif') {
                            return "ssv_valid_extensions";
                        }
                    } else {
                        return "ssv_valid_size_2";
                    }
                } else {
                    return "ssv_valid_required";
                }

                if ($_FILES['doc9']['size']>0) {
                    if($_FILES['doc9']['size']<=7242880) {
                        $fileParts= explode('.', $_FILES['doc9']['name']);
                        $imgext1=strtolower( end($fileParts));
                        if($imgext1!='tiff' && $imgext1!='pdf' && $imgext1!='jpg' && $imgext1!='jpeg' && $imgext1!='tif') {
                            return "ssv_valid_extensions";
                        }
                    } else {
                        return "ssv_valid_size_2";
                    }
                }

                if ($_FILES['doc10']['size']>0) {
                    if($_FILES['doc10']['size']<=7242880) {
                        $fileParts= explode('.', $_FILES['doc10']['name']);
                        $imgext1=strtolower( end($fileParts) );
                        if($imgext1!='tiff' && $imgext1!='pdf' && $imgext1!='jpg' && $imgext1!='jpeg' && $imgext1!='tif') {
                            return "ssv_valid_extensions";
                        }
                    } else {
                        return "ssv_valid_size_2";
                    }
                }


                $validated_inputs = array(
                    "fullName" => $fullName,
                    "dob" => $dob,
                    "employer" => $employer,
                    "Salary" => $Salary,
                    "email" => $email,
                    "mobile" => $mobile,
                    "loanamount" => $loanamount,
                    //"loantype" => $loantype,
                    "workadrress" => $workadrress,
                    "id_name" => $id_name,
                    "id_mobile" => $id_mobile,
                    "id_relation" => $id_relation,
                    "id2_name" => $id2_name,
                    "id2_mobile" => $id2_mobile,
                    "id2_relation" => $id2_relation,
                    "id3_name" => $id3_name,
                    "id3_mobile" => $id3_mobile,
                    "id3_relation" => $id3_relation,
                    "house_no" => $house_no,
                    "street" => $street,
                    "area" => $area,
                    "emirate" => $emirate,
                    "city" => $city,
                    "district" => $district,
                    "doc1" => $_FILES['doc1'],
                    "doc2" => $_FILES['doc2'],
                    "doc3" => $_FILES['doc3'],
                    "doc4" => $_FILES['doc4'],
                    "doc5" => $_FILES['doc5'],
                    "doc6" => $_FILES['doc6'],
                    "doc7" => $_FILES['doc7'],
                    //"doc8" => $_FILES['doc8'],
                    "doc9" => $_FILES['doc9'],
                    "doc10" => $_FILES['doc10']
                );
                return $validated_inputs;
        }
    }

Я увеличил upload_max_filesize до 30 МБ memory_limit 265 post_max_size 30 МБ

Любая причина для этого?

Спасибо.

1 Ответ

0 голосов
/ 09 июня 2018

На вашем веб-сервере также может быть установлен лимит.Например, в Nginx это директива client_max_body_size ( docs ).Эта строка должна быть в вашем server {} блоке:

client_max_body_size 30M;

В Apache у вас есть LimitRequestBody 104800 ( docs ), хотя обычно по умолчанию это 2 ГБ.

Вы должны быть осторожны, изменяя ограничение памяти между прочим.Вы можете выйти на лимит сервера раньше, чем пожелаете.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...