2

I've got a multipart form that's set to accept multiple images from a single field, defined as follows:

echo form_upload('userfile[]', set_value('userfile[]'), 'multiple');

When I run a successful form (using CodeIgniter's built-in validator), it only uploads one image (the last one in the list).

Suspicious, I did a dump of the $_FILES global when the form validated, and it showed the following:

Array
(
    [userfile] => Array
        (
            [name] => image_three.jpg
            [type] => image/jpeg
            [tmp_name] => /tmp/phpZl6RHT
            [error] => 0
            [size] => 18236
        )
)

If I go back and clear out any required field (it doesn't matter which), the same input shows the following in $_FILES:

Array
(
    [userfile] => Array
        (
            [name] => Array
                (
                    [0] => image_one.jpg
                    [1] => image_two.jpg
                    [2] => image_three.jpg
                )
            [type] => Array
                (
                    [0] => image/jpeg
                    [1] => image/jpeg
                    [2] => image/jpeg
                )
            [tmp_name] => Array
                (
                    [0] => /tmp/phpEFaVib
                    [1] => /tmp/phpkcXJmL
                    [2] => /tmp/phpoqcDql
                )
            [error] => Array
                (
                    [0] => 0
                    [1] => 0
                    [2] => 0
                )
            [size] => Array
                (
                    [0] => 43308
                    [1] => 60883
                    [2] => 18236
                )
        )
)

Based on the fact that the incomplete form registers all three images properly, I'm assuming that the form is defined properly, and that something in the validation engine is what's causing it. That said, my attempt to test that assumption by disabling all of the form validation code returned the one-file version of $_FILES. For the record, there are no validation rules tied to the file upload field.

Any ideas on what is causing the form to lose the additional images?

Kaji
  • 2,220
  • 6
  • 30
  • 45

0 Answers0