You are here

README.txt in Plupload integration 7.2

Same filename and directory in other branches
  1. 8 README.txt
  2. 6 README.txt
  3. 7 README.txt
  4. 2.0.x README.txt
This module integrates the Plupload library (available from http://plupload.com)
with Drupal forms. To install the Plupload library:

1. Download it (version 2.1.9 or later) from
   https://github.com/moxiecode/plupload/releases. Version 2.1.9 is supported
   which can be downloaded from https://github.com/moxiecode/plupload/archive/v2.1.9.zip.
2. Unzip it into sites/all/libraries, so that there's a
   sites/all/libraries/plupload/js/plupload.full.min.js file, in addition to the
   other files included in the library.
3. Remove "examples" folder from libraries folder as it could constitute a
   security risk to your site. See http://drupal.org/node/1895328 and
   http://drupal.org/node/1189632 for more info.

If you would like to use an alternate library location, you can install the
http://drupal.org/project/libraries module and/or add

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

to your settings.php file.

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 from 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.'),
  '#autoupload' => TRUE,
  '#autosubmit' => TRUE,
  '#submit_element' => '#id-of-your-submit-element',
  '#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',
  ),
  '#event_callbacks' => array(
    'FilesAdded' => 'Drupal.mymodule.filesAddedCallback',
    'UploadComplete' => 'Drupal.mymodule.uploadCompleteCallback',
  ),
);

There are few optional properties of this array that have special meaning:

-  #autoupload: set this to TRUE if you want Plupload to start uploading
  immediately after files are added.
  Defaults to FALSE.

-  #autosubmit: set this to TRUE if you want Plupload to autosubmit
  your form after automatic upload has finished.
  Defaults to FALSE.
  Has to be used in combination with #autoupload.

-  #submit_element: specify which submit element Plupload shall use to submit
  the form. Can also be used in combination with #autoupload and #autosubmit.
  See: http://drupal.org/node/1935256

- #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' => parse_size(ini_get('post_max_size')) . 'b',
    'unique_names' => TRUE,
    'flash_swf_url' => file_create_url($library_path . '/js/Moxie.swf'),
    'silverlight_xap_url' => file_create_url($library_path . '/js/Moxie.xap'),
  ),

- #event_callbacks - array of callbacks that will be passed to js.
  See full documentation about events in Plupload library:
  http://www.plupload.com/example_events.php

File

README.txt
View source
  1. This module integrates the Plupload library (available from http://plupload.com)
  2. with Drupal forms. To install the Plupload library:
  3. 1. Download it (version 2.1.9 or later) from
  4. https://github.com/moxiecode/plupload/releases. Version 2.1.9 is supported
  5. which can be downloaded from https://github.com/moxiecode/plupload/archive/v2.1.9.zip.
  6. 2. Unzip it into sites/all/libraries, so that there's a
  7. sites/all/libraries/plupload/js/plupload.full.min.js file, in addition to the
  8. other files included in the library.
  9. 3. Remove "examples" folder from libraries folder as it could constitute a
  10. security risk to your site. See http://drupal.org/node/1895328 and
  11. http://drupal.org/node/1189632 for more info.
  12. If you would like to use an alternate library location, you can install the
  13. http://drupal.org/project/libraries module and/or add
  14. $conf['plupload_library_path'] = PATH/TO/PLUPLOAD;
  15. to your settings.php file.
  16. At this time, this module only provides a 'plupload' form element type that
  17. other modules can use for providing multiple file upload capability to their
  18. forms. It does not provide any end-user functionality on its own. This may
  19. change, however, as this module evolves. See http://drupal.org/node/880300.
  20. ---=== For developers ===---
  21. Plupload from element can be used like this:
  22. $form['my_element'] = array(
  23. '#type' => 'plupload',
  24. '#title' => t('Upload files'),
  25. '#description' => t('This multi-upload widget uses Plupload library.'),
  26. '#autoupload' => TRUE,
  27. '#autosubmit' => TRUE,
  28. '#submit_element' => '#id-of-your-submit-element',
  29. '#upload_validators' => array(
  30. 'file_validate_extensions' => array('jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp'),
  31. 'my_custom_file_validator' => array('some validation criteria'),
  32. ),
  33. '#plupload_settings' => array(
  34. 'runtimes' => 'html5',
  35. 'chunk_size' => '1mb',
  36. ),
  37. '#event_callbacks' => array(
  38. 'FilesAdded' => 'Drupal.mymodule.filesAddedCallback',
  39. 'UploadComplete' => 'Drupal.mymodule.uploadCompleteCallback',
  40. ),
  41. );
  42. There are few optional properties of this array that have special meaning:
  43. - #autoupload: set this to TRUE if you want Plupload to start uploading
  44. immediately after files are added.
  45. Defaults to FALSE.
  46. - #autosubmit: set this to TRUE if you want Plupload to autosubmit
  47. your form after automatic upload has finished.
  48. Defaults to FALSE.
  49. Has to be used in combination with #autoupload.
  50. - #submit_element: specify which submit element Plupload shall use to submit
  51. the form. Can also be used in combination with #autoupload and #autosubmit.
  52. See: http://drupal.org/node/1935256
  53. - #upload_validators - an array of validation function/validation criteria pairs,
  54. that will be passed to file_validate().
  55. Defaults to:
  56. '#upload_validators' => array(
  57. 'file_validate_extensions' => array('jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp'),
  58. );
  59. - #plupload_settings - array of settings, that will be passed to Plupload library.
  60. See: http://www.plupload.com/documentation.php
  61. Defaults to:
  62. '#plupload_settings' => array(
  63. 'runtimes' => 'html5,flash,html4',
  64. 'url' => url('plupload-handle-uploads', array('query' => array('plupload_token' => drupal_get_token('plupload-handle-uploads')))),
  65. 'max_file_size' => file_upload_max_size() . 'b',
  66. 'chunk_size' => parse_size(ini_get('post_max_size')) . 'b',
  67. 'unique_names' => TRUE,
  68. 'flash_swf_url' => file_create_url($library_path . '/js/Moxie.swf'),
  69. 'silverlight_xap_url' => file_create_url($library_path . '/js/Moxie.xap'),
  70. ),
  71. - #event_callbacks - array of callbacks that will be passed to js.
  72. See full documentation about events in Plupload library:
  73. http://www.plupload.com/example_events.php