Last updated December 30, 2016. Created on June 19, 2012.
Edited by jasonsavino, atjuch, samwilson, cjoy. Log in to edit this page.

Plupload module integrates the Plupload library with Drupal forms. To install the Plupload library:

  1. Download the latest version of the 1.x branch (currently 1.5.8) from plupload.com.
  2. Unzip it into sites/all/libraries, so that there's a sites/all/libraries/plupload/js/plupload.full.js file, in addition to the other files included in the library.
  3. Delete the "examples" subfolder from Plupload library. There is a patch, that can help you to do this in one simple step or to include it in a distribution.

If you would like to use an alternate library location, you can install the LIbraries module and/or add

  $conf['plupload_library_path'] = 'PATH/TO/PLUPLOAD';

to your settings.php file.

An example of this can be:

  $conf['plupload_library_path'] = 'public://foldername';

At this time, this module only provides a 'plupload' form element type that
other modules can use for providing multiple file upload capability to their
forms. It does not provide any end-user functionality on its own. This may
change, however, as this module evolves. See http://drupal.org/node/880300.

For developers

Plupload form element can be used like this:

$form['my_element'] = array(
  '#type' => 'plupload',
  '#title' => t('Upload files'),
  '#description' => t('This multi-upload widget uses Plupload library.'),
  '#upload_validators' => array(
    'file_validate_extensions' => array('jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp'),
    'my_custom_file_validator' => array('some validation criteria'),
  ),
  '#plupload_settings' => array(
    'runtimes' => 'html5',
    'chunk_size' => '1mb',
  ),
);
  • #upload_validators - an array of validation function/validation criteria pairs, that
    will be passed to file_validate().

    Defaults to:

      '#upload_validators' => array(
        'file_validate_extensions' => array('jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp'),
      );
    
  • #plupload_settings - array of settings, that will be passed to Plupload library.
    See: http://www.plupload.com/documentation.php
      Defaults to:
      '#plupload_settings' => array(
        'runtimes' => 'html5,flash,html4',
        'url' => url('plupload-handle-uploads', array('query' => array('plupload_token' => drupal_get_token('plupload-handle-uploads')))),
        'max_file_size' => file_upload_max_size() . 'b',
        'chunk_size' => '1mb',
        'unique_names' => TRUE,
        'flash_swf_url' => file_create_url($library_path . '/js/plupload.flash.swf'),
        'silverlight_xap_url' => file_create_url($library_path . '/js/plupload.silverlight.xap'),
      ),
    

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

taggartj’s picture

Sorry I don't know if this is the right place to put this but I just wanted to say that this module is awesome
and I was messing around with adding a taxonomy term id to the Plupload system , so users can categorize their uploads better , the following is what i did for drupal 6 but would work for 7 in theory,

Now here is the sad bit, I hate hacking core , however this was the fastest way to do it ... and it is my site so I manage it / update it ect. , any way in Plupload.module line 343 ish in function _plupload_imagefield_import_create_node after ....$node->body = $form_state_values['body'];..

i added:

// ugly hack :(
 if(isset($_GET['tid'])){
// gets an id from url 
	  $node->taxonomy = array($_GET['tid']);
  }else{
// optional if not define default taxonomy id 
	   $node->taxonomy = array(31);
  } 

Then i created a simple view with term id (hidden) and term name then rewight the term name to have a link like :

<a href="http://www.site.com/file-plupload?tid=[tid]" target="_blank">[name]</a>

which now allow me to use taxonomy with Plupload , again thanks for the module a real time saver !

W.M.’s picture

I have tried to implement the code above in one form at my site, but I don't understand how to set the destination path where the file should be saved.

The files get saved to tmp directory. Moreover, I cannot figure out how to get the uploaded files content so I could PHP encode them into base64.

Any ideas? Thanks.

蒲公英’s picture

paulguy’s picture

In order to make it works with D8 (8.2.6) I had to place the library in /libraries/plupload folder (not /sites/all/libraries).
Also plupload module looks for these files :
/libraries/plupload/js/plupload.full.min.js
/libraries/plupload/js/jquery.plupload.queue/jquery.plupload.queue.min.js

There is no .min version of these files in the v1.5.8 library package and had to rename (or minimize) files.
Maybe this doc needs to be updated for Drupal 8 or am I missing something ?

Module plupload 8.x-1.x-dev