奇怪的未定义索引php 5

时间:2017-04-12 18:04:47

标签: php mysql html5

我有一个奇怪的问题,我发送上传一些带有fromt HTML的文件,php没有看到它的问题。这是我的代码:



<input name="files[]" type="file" multiple="multiple" id="uploads" class="form-control"/>
<?php
if(count($_FILES['files']['name']) > 0){
        if (!file_exists("../uploads/projectFiles/$rid")) {
            mkdir("../uploads/projectFiles/$rid", 0777, true);
        }
        //Loop through each file
        for($i=0; $i<count($_FILES['files']['name']); $i++) {
          //Get the temp file path
            $tmpFilePath = $_FILES['files']['tmp_name'][$i];

            //Make sure we have a filepath
            if($tmpFilePath != ""){
            
                //save the filename
                $shortname = $_FILES['files']['name'][$i];

                //save the url and the file
                $filePath = "../uploads/projectFiles/$rid/" . $_FILES['files']['name'][$i];

                //Upload the file into the temp dir
                if(move_uploaded_file($tmpFilePath, $filePath)) {

                    $files[] = $shortname;
                    //insert into db 
                    //use $shortname for the filename
                    //use $filePath for the relative url to the file

                }
              }
        }
    }
&#13;
&#13;
&#13;

它向我显示错误:

未定义的索引:文件

0 个答案:

没有答案