Search code examples
phpfileuploadmultiple-file-upload

php multiple files upload error


I wanna upload multiple files according to passengers number But when I use array it didn't work at all

<?php for ($i = 0; $i < $_REQUEST[select_child]+$_REQUEST[select_adult]; $i++){?>
                        <input type="file" name="scannedFile[]" multiple="multiple" size="40">
                    <?php }?>

The $data[3] is $_REQUEST[select_child], $data[4] is $_REQUEST[select_adult].

for ($i = 1; $i <= $data[3]+$data[4]; $i++){
            $rename = date("YmdHis") . '_' . $_FILES['scannedFile']['name'][$i];
            $target_path = "admin/images/uploads/" .$rename;
            move_uploaded_file($_FILES['scannedFile']['tmp_name'][$i], $target_path);
            echo $rename;
        }

What is the problem..?


Solution

  • Maybe its obvious but, are you set the enctype in form tag?

    enctype="multipart/form-data"