views:

39

answers:

1

Hi,

I am using Jquery Uploadify for images upload with PHP, here i want to upload multiple images in different folders i.e first image will upload into 'folder1' ,2nd image upload into 'folder2' and all these uploads should be done by single instance of uploadify. Is it possible or not??

A: 

Yes, it is possible, but determining which is the first and which is the second file upload etc. is not entirely easy, because for each upload, a new upload.php instance is called.

I would consider passing a random key to the upload script using the scriptData setting:

queueID: 'A10C923302132048AVB'

and in the PHP script, use a session value to count which image the current one is:

$queueID = $_POST["queueID"];

if (isset($_SESSION[$queueID]))
 {
   $imageNumber = $_SESSION[$queueID];
   $_SESSION[$queueID]++;
 }
 else
 {
   $imageNumber = 1;
   $_SESSION[$queueID] = imageNumber;
 }

$imageNumberwill then contain the number of the uploaded image, and you can move_uploaded_file() the upload to the desired location.

Pekka
yes.i tried in same way but session variable value is not changing between calls of upload.php. In first time image call i am setting one session variable and on second image upload call,incrementing the value of that session variable but somehow session variable is not changing i.e not incrementing.
Shatru
@tosha maybe the session is not initialized correctly, that can happen with these Flash-based uploaders. You may have to pass the Session ID in `scriptData` as well.
Pekka
i tried with global variables also but value is not incrementing at all... first i assigned 1 to global variable and after that incrementing global variable value on each image upload... but value is not incrementing.if ($first_time >= 0) {$first_time++ ;} if (empty($first_time)) { global $first_time; $first_time = 1 ; } $returnname = $returnname.'%%'.$first_time ;
Shatru
@tosha global variables will not help you here. As I said, you need to check whether the session gets initialized correctly, and possibly you'll need to send the session ID. See http://stackoverflow.com/questions/2522623/swfupload-destroy-session-php
Pekka
thanks Pekka...
Shatru