README.txt 3.7 KB

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