Drupal 7 and Drupal 8: Install and use in custom form

Last updated on
4 November 2023

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

Drupal 7 library installation:

  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.

Drupal 8 Library installation:

  1. If it doesn't already exist create "libraries" folder in the docroot folder(same level as your modules and themes folders).
  2. Create a folder named "plupload" in the newly created "libraries" folder from step 1.
  3. Per the README.txt for the Drupal 8 version of Plupload module download the Plupload library version 2.1.1 or later from https://github.com/moxiecode/plupload/releases.
  4. Unzip the downloaded Plupload library file and copy the files and folders into the "plupload" folder created in step 2. Do not include the "examples" folder from the downloaded plupload library.

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'),
      ),
    

Help improve this page

Page status: No known problems

You can: