Php $\u文件中的某些键为空

Php $\u文件中的某些键为空,php,html,Php,Html,所以我正在为我妈妈开发一个网站,她想从她的相机上传照片,我首先用在我的电脑上找到的一张普通图片测试了我的代码,这张图片是用photoshop CS6创建的,$\u文件数组还可以: array ( 'img' => array ( 'name' => array ( 0 => 'pic01.jpg', ), 'type' => array ( 0 => 'image/jpeg', ), 'tmp_name' => array ( 0 => 'D:\\xam

所以我正在为我妈妈开发一个网站,她想从她的相机上传照片,我首先用在我的电脑上找到的一张普通图片测试了我的代码,这张图片是用photoshop CS6创建的,$\u文件数组还可以:

array ( 'img' => array ( 'name' => array ( 0 => 'pic01.jpg', ), 'type' => array ( 0 => 'image/jpeg', ), 'tmp_name' => array ( 0 => 'D:\\xampp\\tmp\\phpF0F7.tmp', ), 'error' => array ( 0 => 0, ), 'size' => array ( 0 => 6311, ), ), )
但当我尝试上传我和她的手机照片时,我得到了以下数组:

array ( 'img' => array ( 'name' => array ( 0 => 'IMG_20180228_143837.jpg', ), 'type' => array ( 0 => '', ), 'tmp_name' => array ( 0 => '', ), 'error' => array ( 0 => 1, ), 'size' => array ( 0 => 0, ), ), )
正如您看到的类型一样,tmp_名称和大小为空或不正确(大小不正确)。我还看到错误数组值从0更改为1

这两个数组导出都是通过
var\u导出($\u文件)进行的

我使用以下HTML代码上载图像:

<form method="post" action="updateproduct.php" enctype="multipart/form-data">{
      <input name="img[]" id="fileupload" type="file" multiple />
{

我希望我已经提供了足够的信息,如果没有,请说明。

您的
$\u文件数组中的错误值为1表示您已超过服务器施加的文件大小限制:

上载\u错误\u INI\u大小

值:1;上载的文件超出php.ini中的指令


默认PHP只接受文件上传。在PHP配置中考虑将其更改为更现实的(如200 MB)。也不要忘记增加另一个相关选项,它应该比.

稍大一些。 顺便说一句,这里有一个很好的方法可以将编码错误转换为人类可读的消息:

    function codeToMessage($code) 
    { 
        switch ($code) { 
            case UPLOAD_ERR_INI_SIZE: 
                $message = "The uploaded file exceeds the upload_max_filesize directive in php.ini"; 
                break; 
            case UPLOAD_ERR_FORM_SIZE: 
                $message = "The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form";
                break; 
            case UPLOAD_ERR_PARTIAL: 
                $message = "The uploaded file was only partially uploaded"; 
                break; 
            case UPLOAD_ERR_NO_FILE: 
                $message = "No file was uploaded"; 
                break; 
            case UPLOAD_ERR_NO_TMP_DIR: 
                $message = "Missing a temporary folder"; 
                break; 
            case UPLOAD_ERR_CANT_WRITE: 
                $message = "Failed to write file to disk"; 
                break; 
            case UPLOAD_ERR_EXTENSION: 
                $message = "File upload stopped by extension"; 
                break; 

            default: 
                $message = "Unknown upload error"; 
                break; 
        } 
        return $message; 
    }