fileScript() static public method

fileScript : file upload script
static public fileScript ( $options = [] ) : nothing
$options array of possible options: - imagePaste boolean image paste with tinyMce - name string field name (default filename) - multiple boolean allow multiple file upload (default false) - onlyimages boolean restrict to image files (default false) - showfilecontainer string DOM ID of the container showing file uploaded: use selector to display - pasteZone string DOM ID of the paste zone - dropZone string DOM ID of the drop zone - rand string already computed rand value
return nothing (print the image paste)
Example #1
0
 /**
  * imagePaste : Show image paste for an item, with TinyMce
  *
  * @since version 0.85
  *
  * @param $options       array of options
  *     - name              string   field name (default filename)
  *     - multiple          boolean  allow multiple file upload (default false
  *     - onlyimages        boolean  restrict to image files (default false)
  *     - showfilecontainer string   DOM ID of the container showing file uploaded:
  *                                  use selector to display
  *     - imagePaste        boolean  image paste with tinyMce
  *     - dropZone          string   DOM ID of the drop zone
  *     - rand              string   already computed rand value
  *     - pasteZone         string   DOM ID of the paste zone
  *
  * @return nothing (print the image paste)
  **/
 static function imagePaste($options = array())
 {
     $rand = mt_rand();
     $p['name'] = 'stock_image';
     $p['multiple'] = true;
     $p['onlyimages'] = true;
     $p['showfilecontainer'] = 'fileupload_info';
     $p['imagePaste'] = 1;
     $p['dropZone'] = 'image_paste';
     $p['rand'] = $rand;
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $p[$key] = $val;
         }
     }
     echo '<script type="text/javascript">';
     echo Html::fileScript($p);
     echo '</script>';
     echo "<div class='fileupload' id='" . $p['dropZone'] . "'></div>\n";
 }