简体   繁体   中英

codeigniter multiple file upload at once using a single input field

I am having a problem in uploading multiple files at once using a single input field,

My HTML form looks like this

<form method="post" action="upload.php" enctype="multipart/form-data">
    <input type="file" name="files[]" multiple/>
    <input type="submit" />
</form>

In my controller I am checking like this

echo "<pre>; print_r($_FILES); die; 

And when I select 2 pdf files, I am getting the output like this

Array
(
[files] => Array
    (
        [name] => Array
            (
                [0] => myfile.pdf
            )

        [type] => Array
            (
                [0] => 
            )

        [tmp_name] => Array
            (
                [0] => 
            )

        [error] => Array
            (
                [0] => 1
            )

        [size] => Array
            (
                [0] => 0
            )

    )

 )

I should be getting 2 array in the output right? So, what is the problem here?

try the following code in your controller:

echo "<pre>"; 
$_FILES['files']; // change over here
die();

Try following

print_r($_FILES['files']);

If that didn't work, following should work

print_r($_FILES['files[]']);

Also take a look athere

Error value 1: UPLOAD_ERR_INI_SIZE The uploaded file exceeds the upload_max_filesize directive in php.ini. (- source )

You can set those within your code by

ini_set('max_file_uploads',1000);
ini_set('post_max_size','5000M');
ini_set('upload_max_filesize','5000M');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM