Skip to content

Multiple file input #134

Open
Open
@mvilskersts

Description

@mvilskersts

I believe there is a problem with bootstrap file input when using attribute "multiple".

In order to correctly upload multiple files i have to define my file input as array. For example:
<?= $this->Form->input( 'images[]', [ 'multiple' => true, 'type' => 'file'] ); ?>

This creates the file upload widget that includes a fake input for displaying number of files chosen:
<input type="text" name="images[]-text" class="form-control" readonly="readonly" id="images-input" onclick="document.getElementById('images').click();" value="">

Here is where the problem is:
When I dump the contents of $_FILES super global variable all the chosen files are there as expected. However, if I dump $this->request->data one of the files is missing because the fake text input overrides it. What I propose is to replace readonlyattribute on the fake input with a disabled so that it doesn't get submitted (which proved to fix the issue for me).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions