0

Are there any solutions to upload multiple files at once without flash? :)

Not like that: choose one file, it goes to the stock, choose second file, it goes to the stock and than upload. But choose at once all needed files and upload them.

1
  • Maybe upload one by one, after one is finished then start other one? Commented Mar 6, 2011 at 16:49

2 Answers 2

3

HTML5 supports multiple files, by specifying the "multiple" attribute on the input.

Give the input a name attribute ending in square brackets (i.e. "myfileinput[]") and it will appear to PHP exactly the same as if there were two inputs called the same thing on the page.

This obviously doens't work in legacy browsers, however lack of support for multiple file uploads could be detected via JS, and multiple file inputs created via JS.

Sign up to request clarification or add additional context in comments.

Comments

1

You can have multiple file input fields:

<input type="file" name="file1" />
<input type="file" name="file2" />
etc...

or

<input type="file" name="file[]" />
<input type="file" name="file[]" />

They can be created dynamically via Javascript, or created in advance from the server. Either way, you get multiple files uploaded, though only file per input field.

The first option will work as expected. You'll get one $_FILES array entry per file in PHP. The other option, with the array notation, works a bit counter-intuitively. You get something that looks like

$_FILES = array(
   'file' => array(
       'name' => array(
            0 => 'name of first file',
            1 => 'name of second file
        ),
        'type => array(
            0 => 'mime type of first file',
            1 => 'mime type of second file',
     etc....

2 Comments

Maybe my english is bad, but i've wrote: "Not like that: choose one file, it goes to the stock, choose second file, it goes to the stock and than upload. But choose at once all needed files and upload them." :)
Until HTML5 become standard and widespread, this is the only practical way of supporting it in all browsers, without using anything client-side beyond simple html.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.