TCM
TCM

Reputation: 16900

How do i get all files on server side

I am using uploadify plugin of jquery and have set multiple files upload to true. How do i retrieve these files on the server side?

We need to specify file input name in files array $_FILES['fileInputName']. But i have only 1 file input present on the form which is submitting multiple files. How do i retrieve them all?

Thanks in advance :)

Upvotes: 0

Views: 253

Answers (2)

Pekka
Pekka

Reputation: 449415

Uploadify invokes an upload script for each uploaded file separately.

As far as I know, there is no way to tell inside the PHP upload script whether the current upload is the final one in the queue.

You need to make use of the onComplete and onAllComplete callbacks on client side. Inside onComplete, you would add each succeeded upload to an array. In onAllComplete, you could make an Ajax request sending the list of uploaded files to a PHP script.

Uploadify docs

Upvotes: 3

andres descalzo
andres descalzo

Reputation: 14967

foreach

PHP:

foreach ($_FILE as $key => $value) {
    echo "_FILE : $key; Valor: $value<br />\n";
}

but if the jquery plugin sends the files one by one, you should save the data files in the user session.

if (!isset($_SESSION['FILES_UPLOAD']))
   $_SESSION['FILES_UPLOAD'] = array();

foreach ($_FILE as $key => $value) {
    $_SESSION['FILES_UPLOAD'][$key] =$value;
}

Upvotes: -1

Related Questions