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 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题