Chris
Chris

Reputation: 31

jquery plupload multipart_params

I'm using "plupload" plugin.

I have this input form :

<div id="flash_uploader" style="width: 610px; height: 330px;">You browser doesn't have Flash installed.</div><input type="text" name="categorie" id ="categorie" value="" /><input type="submit" value="send" />

I try to get the value of "categorie" with "multipart_params" but this doesn't work !

$("#flash_uploader").pluploadQueue({
    // General settings
    runtimes : 'flash',
    url : '../scripts/plupload/examples/upload.php',
    max_file_size : '700kb',
    chunk_size : '1mb',
    unique_names : false,
    multi_selection : true,
    multipart : true,
    multipart_params : {categorie : $('#categorie').val()},
    filters : [
        {title : "Image files", extensions : "jpg,png"}
    ],
    // Resize images on clientside if we can
    resize : {width : 550, height : 550, quality : 94},
    // Flash settings
    flash_swf_url : '../scripts/plupload/js/plupload.flash.swf'
});

How can I send the input "categorie" value in the pluploadQueue to ../scripts/plupload/examples/upload.php ?

Thanks for your help...

Upvotes: 3

Views: 10657

Answers (3)

Rik Lewis
Rik Lewis

Reputation: 749

In the latest version of Plupload there are a few changes...

  1. BeforeUploadChunk event (recommended in examples on Plupload website) no longer fires
  2. multipart_params is now deprecated, replaced with params
  3. You should use setOptions instead of setting the object properties directly

This is the snippet that worked for me...

var uploader = new plupload.Uploader({
  //snip
  init: {
    UploadFile: function(up,file) {
      up.setOption("params",{file_id:file.id});
    }
  }
};
uploader.init();

Upvotes: 1

Marco
Marco

Reputation: 1

if you have the basic javascript upload (provided in the example) you can use this: (assuming you have an input id="nuova_categoria" and/or input id="categoria_esistente")

init: {
    PostInit: function() {
        document.getElementById('filelist').innerHTML = '';

        document.getElementById('uploadfiles').onclick = function() {
            uploader.settings.multipart_params.new_cat = $('#nuova_categoria').val();
            uploader.settings.multipart_params.existing_cat = $('#categoria_esistente').val();
            uploader.start();
            return false;
        };
    }, 

it triggers 'onclick' the value in those input fields. Hope this will help. Marco - www.infoarredo.it

Upvotes: 0

loushizan
loushizan

Reputation: 79

After block

$("#flash_uploader").pluploadQueue({...})

Bind BeforeUpload event

var uploader = $('#flash_uploader').pluploadQueue();
uploader.bind('BeforeUpload', function(up) {
  up.settings.multipart_params.tags = $('#categorie').val();
});

It works for me, hope it can solve your problem.

Upvotes: 8

Related Questions