James Wood
James Wood

Reputation: 17562

How can I alllow the selection of multiple files in multiple selections?

How can I alllow the selection of multiple files in multiple selections?

For example using this code snippet:

Select files: <input type="file" name="myFile" multiple>

  1. Click 'Browse'; select a file.
  2. Click 'Browse'; select another file.

This results in only the second file being selected. I want both files to be selected. Is this possible using the basic input control?

Upvotes: 0

Views: 43

Answers (1)

Quentin
Quentin

Reputation: 943569

Not in any practical way.

The implementation of the UI for a file input is browser dependant (and most browsers just implement the standard control for the OS). You can't change that.

The closest you could get would probably be to do something along the lines of, in response to a file being selected, duplicating the input and hiding the original. Then a second interaction would change the selection of the newest input while preserving the older ones.

This would break the normal mechanisms provided for users to deselect previously chosen options and be inconsistent with the behaviour of file selection on other sites so I'd strongly advise against it.

Upvotes: 1

Related Questions