Aadam
Aadam

Reputation: 1541

plupload data showing null in post

i am posting some json string, which i can see in alert also, but that is not getting posted, i am making tht string from DOM, instead when i manually make a jsonarray, its getting posted. below is the code, please check and tell the mistake.

function plupload(){ 

    $("#uploader").pluploadQueue({
        // General settings
        runtimes : 'html5,gears,browserplus,silverlight,flash,html4',
        url : 'uploads',
        max_file_size : '10mb',
        unique_names : false,
        chunk_size: '2mb',
        // Specify what files to browse for
        filters : [
            {title: "Image files", extensions: "jpg,gif,png"},
            {title: "Zip files", extensions: "zip"}
        ],
        resize: {width: 320, height: 240, quality: 90},

        // Flash settings
        flash_swf_url : 'plup/Moxie.swf',
        // Silverlight settings
        silverlight_xap_url : 'plup/Moxie.xap',
        multipart_params: {'stringObj': JSON.stringify(datas), 'time': '2012-06-12'}
    });
       $("#uploader").pluploadQueue().bind('BeforeUpload', function(up, files) {
                $('#uids li').each(function() {
                    var data = { 
                        uid: $(this).text() 
                    };
                    datas.push(data);
                 });
                 alert(JSON.stringify(datas));
        });  
    }
plupload();
$('#clear').click(function(){
    plupload();
});

there is bind beforeupload event. and i can see the json string in alert also, the var datas[] is declared above all the functions.

thanks and regards

Upvotes: 0

Views: 545

Answers (1)

Aadam
Aadam

Reputation: 1541

k. I have done this to send data to server with multipart params of plupload. Solved now

$("#uploader").pluploadQueue().bind('BeforeUpload', function(up) {
                $('#uids li').each(function() {
                    var data = { 
                        uid: $(this).text() 
                    };
                    datas.push(data);
                 });
                 up.settings.multipart_params =
                    {
                        'stringObj': JSON.stringify(datas)
                    };
                 alert(JSON.stringify(datas));
        });  

Upvotes: 1

Related Questions