为什么提交带有 5 mb 文件的表单不起作用,但它在 php yii 框架中使用 4mb?



希望一切都好。

我是一名 ASP.Net 开发人员,但是我现在使用的是php yii框架。

我有一个表格,可以在其中附加文件。

在表单提交中,我正在对电子邮件地址和姓名进行一些验证。

我很有趣这种方法$this->validateInput($_POST['FullName'](;

当我在表单中附加 5mb 文件时,验证不起作用。

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

它ssv_fullname回报了我。

但是,当我附加小于 5 mb 时,一切正常,表单被提交。

这是我的验证方法:

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 MB memory_limit 265 post_max_size 30 MB

有什么原因吗?

谢谢。

您的网络服务器可能也设置了限制。例如,在Nginx中,它是client_max_body_size指令(docs(。您应该在server {}块中包含以下行:

client_max_body_size 30M;

在 Apache 中,您有LimitRequestBody 104800(文档(,尽管通常默认设置为 2 GB。

顺便说一下,您应该小心更改内存限制。您可能会比您希望的更早达到服务器限制。

最新更新