Function:
$form->addFileUpload($type, $name, $value, $label, $attr, $fileUpload_config, $current_file);
Arguments:
- $type [String]
- The field type
Usually: file
- $name [String]
- The field name
- $value[String]
- The field value
- $label [String]
- The field label
- $attr [String]
- The field attributesdocumentation
- $fileUpload_config[optional] [Array]
- the plugin configuration node in phpformbuilder/plugins-config/fileuploader.xml
See Ready-to-use configurations below
- $current_file [Array]
- File data if the uploader has to be loaded with an existing file.
Useful for update purpose.
Example of use here: templates/bootstrap-4-forms/fileupload-test-form.php
Ready-to-use configurations
File Uploader is supplied with several ready xml configs:
- 'default'
- uploader: phpformbuilder/plugins/fileuploader/default/php/ajax_upload_file.php
- 'image-upload'
- uploader: phpformbuilder/plugins/fileuploader/drag-and-drop/ajax_upload_file.php
- 'drag-and-drop'
- uploader: phpformbuilder/plugins/fileuploader/image-upload/php/ajax_upload_file.php
$fileUpload_config - default configuration
$default_config = array(
'xml' => 'default',
'uploader' => 'ajax_upload_file.php',
'upload_dir' => '../../../../../file-uploads/',
'limit' => 1,
'extensions' => ['jpg', 'jpeg', 'png', 'gif'],
'file_max_size' => 5,
'thumbnails' => false,
'editor' => false,
'width' => null,
'height' => null,
'crop' => false,
'debug' => false
);
$fileUpload_config - arguments
- 'xml' [String]
- name of the XML configuration node called in phpformbuilder/plugins-config/fileuploader.xml
- 'uploader' [String]
- name of the PHP uploader file in phpformbuilder/plugins/fileuploader/[xml-node-name]/
- 'upload_dir' [String]
- path from the PHP uploader (ie: phpformbuilder/plugins/fileuploader/default/php/ajax_upload_file.php) to the upload directory
- 'limit' [Int]
- Maximum number of uploaded files
- 'extensions'[Array]
- Array with the allowed extensions
- 'file_max_size'[Int]
- maximal file size in MB
- 'thumbnails'[Boolean]
- For image upload - Create thumbnails (true|false) - thumbnails can be configured in the PHP image uploader in phpformbuilder/plugins/fileuploader/image-upload/php/ajax_upload_file.php
- 'editor'[Boolean]
- For image upload - uploaded images can be clicked & edited by user (true|false)
- 'width'[Int|null]
- For image upload - maximum image width in px. null = no limitation
- 'height'[Int|null]
- For image upload - maximum image height in px. null = no limitation
- 'crop'[Boolean]
- For image upload - crop image to fit the given width & height (true|false)
- 'debug'[Boolean]
- log errors in the browser console (true|false)
You can easily deal with uploaded files, thumbnails and images sizes in plugins/fileuploader/[xml]/php/[uploader].php
Other examples with code are available in Templates