提交带有文件上传的表单不会在post变量中发送提交

提交带有文件上传的表单不会在post变量中发送提交

问题描述:

I have a problem. I'm able to upload some file but not all of them. In phpinfo, the upload_max_filesize is set to 64M. The file bigger than 3Mo doesn't send the $_POST["submit"] (when I do a var_dump)... And I got no error message...

var_dump($_POST);

if(ISSET($_POST["submit"])) {
    while($rowSecteur=getRowElement($resultListeSecteur)){
        if (ISSET($_FILES["fileToUpload".$rowSecteur['IDSecteur']])) {
            $target_dir = "uploads/";
            $target_file = $target_dir . basename($_FILES["fileToUpload".$rowSecteur['IDSecteur']]["name"]);
            $uploadOK = 1;
            $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);

            // Check if image file is a actual image or fake image
            if(!empty($_FILES["fileToUpload".$rowSecteur['IDSecteur']]["tmp_name"])){
                $check = getimagesize($_FILES["fileToUpload".$rowSecteur['IDSecteur']]["tmp_name"]);
                if($check !== false) {
                    $uploadOK = 1;
                    include 'uploadPlan.php';
                }
                else {
                    $msg = '<div id="msg" class="alert alert-error">
                        <button type="button" class="close" data-dismiss="alert">&times;</button>
                        <h4 class="alert-heading">'._("Error!").'</h4>
                        <p>'. _("The file ' ").$_FILES['fileToUpload'.$rowSecteur['IDSecteur']]['name']._(" ' must be an image or the file size is incorrect.").'</p>
                    </div>';
                    $uploadOK = 0;
                }
            }
        }
    }

form code :

<form id="formMapSecteur" class="form-horizontal" method="post" action="selectMap.php">
    <div id="fileBrowser<?php echo $rowSecteur['IDSecteur']?>" class="form-group form-inline col-sm-4">
        <input type="file" name="fileToUpload<?php echo $rowSecteur['IDSecteur']?>" id="fileToUpload<?php echo $rowSecteur['IDSecteur']?>">
    </div>
    <div class="form-group form-inline col-sm-4 pull-right">
        <button name="submit" type="submit" class="btn btn-primary"><?php echo _("Save")?></button>
    </div>
</form>

Does someone understand what's going wrong in my code?

Here's the result of the var_dump when the file is smaller than 3Mo (exactly 2.85Mo) : array (size=1) 'submit' => string '' (length=0)

and when the file is bigger than 3Mo (3.13Mo): array (size=0) empty

The post_max_size was set to 3M so I set it to 8M

Thanks to Tristan for the solution.