2015-12-07 86 views
0

我有一个问题。我能够上传一些文件,但不是全部。在phpinfo中,upload_max_filesize设置为64M。该文件比3MO大不发送$ _POST [ “提交”](当我做了的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> 

有人知道我的代码中出了什么问题吗?

这里的的var_dump结果当文件超过3MO(确切2.85Mo)小: array (size=1) 'submit' => string '' (length=0)

,并在文件大于3MO(3.13Mo)更大: array (size=0) empty

+1

表单元素缺失'enctype =“multipart/form-data”' – Tristan

+0

我认为这是问题,我不知道为什么我没有放它,习惯上,我总是把它放在表单标签中。 ..但我已经尝试过,没有什么改变... – sincos

+1

下一个检查是php.ini'post_max_size'值 – Tristan

回答

0

将post_max_size设置为3M,因此我将其设置为8M

感谢Tristan提供的解决方案。