Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP $_FILES multiple file uploading problem

I have a little problem with uploading multiple files in PHP ,

i have this html form:

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

and this is the upload.php :

<?php print_r( $_FILES ); ?> 

when i'm sending a file it show me this:

 Array
(
[myfile] => Array
    (
        [name] => Array
            (
                [0] => Krw_Qe4QKmI.mp3
            )

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

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

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

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

    )

 )

so far so good.

the problem starts when i upgrade my form to this one :

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

now , when i send 2 files , it show me this :

Array
(
)

so , what's the problem here? thank you , Mor.

like image 786
homerun Avatar asked Sep 18 '11 18:09

homerun


1 Answers

I would bet that you exceeded post_max_size and PHP just ignored the uploaded files.

It's 8MB by default. If you try to upload one 5MB file everything will work. If you try to upload 2 5MB files, it exceeeds 8MB and PHP ignores posted data.

Try increasing the value of post_max_size in your php.ini.

like image 157
Arnaud Le Blanc Avatar answered Oct 30 '22 10:10

Arnaud Le Blanc