Usage in a custom form

Last updated on
4 November 2023

This documentation needs work. See "Help improve this page" in the sidebar.

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

An array of settings, that will be passed to Plupload library. See https://www.plupload.com/docs/

Defaults to (needs review):

#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: Needs work

You can: