Topic: Second button for browse dialog

I have a link...

<a id="pickfiles" href="#">Select files</a>

...which is used for the browse_button parameter

browse_button : 'pickfiles',

How can I have a second link also open the browse dialog?

Re: Second button for browse dialog

http://www.plupload.com/punbb/viewtopic.php?id=1699

Re: Second button for browse dialog

Thanks for the link, wasn't able to find it before.

Though I'm not using the queue widget but the custom upload: http://www.plupload.com/example_custom.php

How would this work using this example?

Re: Second button for browse dialog

in the custom uploader
use the variable you used to store the uploader


var up = new plupload.Uploader({...

Re: Second button for browse dialog

Thanks, it works now!

Accidentally also replaced plupload.addEvent to up.addEvent, which gave an error of course.

But restored that variable and it's working like a charm. Thanks again.

Re: Second button for browse dialog

I'm in a situation similar to this.

I've got a list of groups, need to upload contacts to a specific group, i'm trying to trigger the dialog box once a user clicks on a specific group link, which basically means there's a list of dynamic browse buttons, pasting below the links, which displays a list of 5 groups

       <a id="pickfiles 1" href="#">Upload File</a>
      <a id="pickfiles 2" href="#">Upload File</a>
      <a id="pickfiles 3" href="#">Upload File</a>
      <a id="pickfiles 4"  href="#">Upload File</a>
      <a id="pickfiles 5" href="#">Upload File</a>

I'm able to trigger dialog boxes for each of these links but want to fetch the group id which resides besides the id value pickfiles, I've got a way to do this, but it's always returning the value  1(which is the value of first group id) even if i click on the link of a different group, I reckon it's due to assigning the same browse button id to all groups.

Can anyone advise me on a method other than this so that  i can fetch the value of each corresponding group properly.

Last edited by allanxavierm (2012-09-03 10:50:14)

Re: Second button for browse dialog

Did a little test for you and that seems to work. Assuming you also use jquery you can add trigger to the click event on your link.

For example:

You have a hidden input type to store the group id in.

<input type="hidden" name="group_id" id="group_id">

Add the trigger to the click event.

  $('#a').click(function() {
    $('#group_id').val($(this).attr('id'));
  });

And use the preinit parameter in your Uploader instance.

...
    preinit : {
      UploadFile: function(up, file) {
        up.settings.multipart_params = {
          group_id: $('#group_id').val()
        }
      }
    }
...

Now you can use $_REQUEST['group_id'] in you upload handler. Perhaps this can be done a bit more smart but the idea should work.

Re: Second button for browse dialog

Igua, thanks for the prompt response.

As you mentioned i'm using a hidden field to hold the group id, but my actual problem is not that, i need a method to differentiate the click events, as of now all click events are linked to the browse button 'pickfiles' and as i've a dynamic list of browse button all clicks are linked to the first browse button, need to differentiate these click events so that i can make sure that this event was launched by the browse button with a particular group id

Last edited by allanxavierm (2012-09-04 06:20:52)

Re: Second button for browse dialog

Not really sure what you're trying to accomplish and why you couldn't use $('#group_id').val($(this).attr('id')); for this in the method you're calling. You can also use a global javascript variable for this.

Other option I'm thinking about is creating a seperate instance for each link, but this also sounds like an overkill.

Perhaps you can give the piece of code you're trying to build?