douqian9729 2015-12-07 22:09
浏览 68
已采纳

提交带有文件上传的表单不会在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

  • 写回答

1条回答 默认 最新

  • doudou130216 2015-12-08 15:08
    关注

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

    Thanks to Tristan for the solution.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算