0

I have a weird problem, I send uploading some files with the fromt HTML, the problem that the php doesn't see it. here is my code :

<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

                }
              }
        }
    }

it shows me that error :

Undefined index: files

0 Answers0