簡體   English   中英

帶有文件上傳的提交表單不會在post變量中發送提交

[英]Submit form with file upload doesn't send submit in the post variable

我有個問題。 我可以上傳一些文件,但不是全部。 在phpinfo中, upload_max_filesize設置為64M 大於3Mo的文件不會發送$ _POST [“ submit”](當我執行var_dump時)...並且我沒有收到任何錯誤消息...

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 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>

有人知道我的代碼出了什么問題嗎?

這是文件小於3Mo(恰好是2.85Mo)時var_dump的結果: array (size=1) 'submit' => string '' (length=0)

當文件大於3Mo(3.13Mo)時: array (size=0) empty

post_max_size設置為3M,所以我將其設置為8M

感謝Tristan提供的解決方案。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM