Phoexo
Phoexo

Reputation: 2556

How to change order of files in multiple file input?

The files are ordered alphabetically by default; is there any way to upload them in the order they were chosen in the file picker instead?

I want to be able to select a primary file and then other extra files in the same input without having to submit more than one input/time.

Upvotes: 14

Views: 10093

Answers (1)

pishpish
pishpish

Reputation: 2614

The files are actually not ordered alphabetically. They are lined in the order of appearance in the file picker (at least that is how current Chrome and Firefox work on Windows 7). You simply had them sorted by name in the picker.

I don't think what you're asking is possible. You could either:

  • instruct the user to make sure the primary file is always first in the list (however, I believe there is no guarantee of the order by browsers).
  • create a separate input element for the primary file.
  • (recommended) display the file names (and/or content) and allow the user to select the file he wishes to be primary. Store that information in some hidden field with JavaScript.

Upvotes: 10

Related Questions