views:

51

answers:

1

In uploadify I have a problem passing variable into the php script. Here's the code:

$(document).ready(function() {
    var counter = 0;

    $("#uploadify").uploadify({

        'uploader'       : 'scripts/uploadify.swf',
        'script'         : 'scripts/uploadify.php?upload',
        'scriptData'     : {'PHPSESSID' : '<? echo session_id(); ?>','counter' : counter},
        'cancelImg'      : 'cancel.png',
        'folder'         : 'uploads',
        'auto'           : true,
        'multi'          : false,
        'buttonText'     : 'Browse Image',
        onComplete: function(evt, queueID, fileObj, response, data) {
            loadPhotos();
            counter = $(".upload-photo").size();
            alert("Success: "+counter+" Response: "+response);
        }
    });
});

In onComplete response var should return the value of $_REQUEST['counter']. It returns 0 because counter = 0 in the beginning but it is not updating at:

counter = $(".upload-photo").size();

I also tried to pass the variable like this:

$("#uploadify").uploadifySettings("scriptData", {'counter' : $(".upload-photo").size()});

But it didn't work either. What am I doing wrong?

A: 

Not sure what I was doing wrong but after some time spent tinkering sessions started working fine. Thank you every each of you for help.

marcin_koss