Topic: Multipart-Params problems!?

Hello together,

first thanks for this great uploader!!!

I have some problems with multipart-params.
first i included my parms in "new plupload.Uploader(..." and all worked fine!!

Now i have to use some variables direct from code. In this case: "$('#cat_id').val()".
I tought i can do it with this code:

uploader.bind('BeforeUpload', function(up,file){
        up.settings.multipart_parms = {
            cat_id : $('#cat_id').val(), 
            ajax : 'addcatimage'
        };
    });

but this didnt work. If i do so no params will be submitted via POST!

Can somebody help me? I can`t find my error :s

Thanks in advance.

Here is my complete code:


$(document).ready(function(){
    var uploader = new plupload.Uploader({
        runtimes : 'html5',
        browse_button : 'catimage',
        container : 'catimagecontainer',
        max_file_size : '2mb',
        url : '/articlelist',
        filters : [
            {title : "Image files", extensions : "jpg,gif,png"}
        ]
    });



    uploader.init();
    
    uploader.bind('BeforeUpload', function(up,file){
        up.settings.multipart_parms = {
            cat_id : $('#cat_id').val(), 
            ajax : 'addcatimage'
        };
    });
    
    uploader.bind('FilesAdded', function(up, files) {
        
        $.each(files, function(i, file) {
            uploader.start();
        });

        up.refresh(); // Reposition Flash/Silverlight
    });

    uploader.bind('Error', function(up, err) {
        alert("Error: " + err.code +
            ", Message: " + err.message +
            (err.file ? ", File: " + err.file.name : ""));
        up.refresh(); // Reposition Flash/Silverlight
    });

    uploader.bind('FileUploaded', function(up, file, response) {
        alert(response.response);
    });
});

Re: Multipart-Params problems!?

Your url parameter is wrong.

url : '/articlelist',

This should be pointing to a file (like upload.php in the examples) not a folder.

It should look something like this:

url : '../upload.php',

Re: Multipart-Params problems!?

Zapper wrote:

Your url parameter is wrong.

url : '/articlelist',

This should be pointing to a file (like upload.php in the examples) not a folder.

Hello Zapper,

first thx for your answer.
But /articlelist is a file ;-)

I do a rewrite via htaccess to a filename.
The only problem are the multipart-formdata, which not will be sent via POST

Re: Multipart-Params problems!?

This problem is raised a great deal on the forum.  If you look through the old posts you should find the solution.

Re: Multipart-Params problems!?

Solution example:

// they have to be defined at the start
//(1) in $("#uploader").pluploadQueue({}), add following to initialize:
multipart_params: { 'title': '','comment': '' },

//(2) add the following right after $("#uploader").pluploadQueue({}).
var uploader = $('#uploader').pluploadQueue();
uploader.bind('FilesAdded', function(up, files) {
 uploader.settings.multipart_params.title = $("#title").val();
 uploader.settings.multipart_params.comment = $("#comment").val();
});

Last edited by deslooverej (2012-02-23 15:59:19)