-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Uploader
Arguments
-
settings
Object
For detailed information about each option check documentation.-
browse_button
String|DOMElement
id of the DOM element or DOM element itself to use as file dialog trigger. -
url
String
URL of the server-side upload handler. -
[chunk_size=0]
Number|String
Chunk size in bytes to slice the file into. Shorcuts with b, kb, mb, gb, tb suffixes also supported.e.g. 204800 or "204800b" or "200kb"
. By default - disabled. -
[container]
String
id of the DOM element to use as a container for uploader structures. Defaults to document.body. -
[drop_element]
String|DOMElement
id of the DOM element or DOM element itself to use as a drop zone for Drag-n-Drop. -
[file_data_name="file"]
String
Name for the file field in Multipart formated message. -
[filters=[]
Array
Set of file type filters, each one defined by hash of title and extensions.e.g. {title : "Image files", extensions : "jpg,jpeg,gif,png"}
. Dispatchesplupload.FILE_EXTENSION_ERROR
-
[flash_swf_url]
String
URL of the Flash swf. -
[headers]
Object
Custom headers to send with the upload. Hash of name/value pairs. -
[max_file_size]
Number|String
Maximum file size that the user can pick, in bytes. Optionally supports b, kb, mb, gb, tb suffixes.e.g. "10mb" or "1gb"
. By default - not set. Dispatchesplupload.FILE_SIZE_ERROR
. -
[max_retries=0]
Number
How many times to retry the chunk or file, before triggering Error event. -
[multipart=true]
Boolean
Whether to send file and additional parameters as Multipart formated message. -
[multipart_params]
Object
Hash of key/value pairs to send with every file upload. -
[multi_selection=true]
Boolean
Enable ability to select multiple files at once in file dialog. -
[prevent_duplicates=false]
Boolean
Do not let duplicates into the queue. Dispatchesplupload.FILE_DUPLICATE_ERROR
. -
[required_features]
String|Object
Either comma-separated list or hash of required features that chosen runtime should absolutely possess. -
[resize]
Object
Enable resizng of images on client-side. Applies toimage/jpeg
andimage/png
only.e.g. {width : 200, height : 200, quality : 90, crop: true}
-
[width]
Number
If image is bigger, it will be resized. -
[height]
Number
If image is bigger, it will be resized. -
[quality=90]
Number
Compression quality for jpegs (1-100). -
[crop=false]
Boolean
Whether to crop images to exact dimensions. By default they will be resized proportionally.
-
[width]
-
[runtimes="html5,flash,silverlight,html4"]
String
Comma separated list of runtimes, that Plupload will try in turn, moving to the next if previous fails. -
[silverlight_xap_url]
String
URL of the Silverlight xap. -
[unique_names=false]
Boolean
If true will generate unique filenames for uploaded files.
-
browse_button
Unique id for the Uploader instance.
### [state](/moxiecode/plupload/blob/master/src/plupload.js#L1009 "Defined at: src/plupload.js:1009")Current state of the total uploading progress. This one can either be plupload.STARTED or plupload.STOPPED. These states are controlled by the stop/start methods. The default value is STOPPED.
### [features](/moxiecode/plupload/blob/master/src/plupload.js#L1018 "Defined at: src/plupload.js:1018")Map of features that are available for the uploader runtime. Features will be filled before the init event is called, these features can then be used to alter the UI for the end user. Some of the current features that might be in this map is: dragdrop, chunks, jpgresize, pngresize.
### [runtime](/moxiecode/plupload/blob/master/src/plupload.js#L1028 "Defined at: src/plupload.js:1028")Current runtime name.
### [files](/moxiecode/plupload/blob/master/src/plupload.js#L1036 "Defined at: src/plupload.js:1036")Current upload queue, an array of File instances.
### [settings](/moxiecode/plupload/blob/master/src/plupload.js#L1045 "Defined at: src/plupload.js:1045")Object with name/value settings.
### [total](/moxiecode/plupload/blob/master/src/plupload.js#L1053 "Defined at: src/plupload.js:1053")Total progess information. How many files has been uploaded, total percent etc.
## Methods ### [init()](/moxiecode/plupload/blob/master/src/plupload.js#L1062 "Defined at: src/plupload.js:1062")Initializes the Uploader instance and adds internal event listeners.
### [refresh()](/moxiecode/plupload/blob/master/src/plupload.js#L1431 "Defined at: src/plupload.js:1431")Refreshes the upload instance by dispatching out a refresh event to all runtimes. This would for example reposition flash/silverlight shims on the page.
### [start()](/moxiecode/plupload/blob/master/src/plupload.js#L1442 "Defined at: src/plupload.js:1442")Starts uploading the queued files.
### [stop()](/moxiecode/plupload/blob/master/src/plupload.js#L1456 "Defined at: src/plupload.js:1456")Stops the upload of the queued files.
### [disableBrowse(disable)](/moxiecode/plupload/blob/master/src/plupload.js#L1470 "Defined at: src/plupload.js:1470")Disables/enables browse button on request.
Arguments
-
disable
Boolean
Whether to disable or enable (default: true)
Returns the specified file object by id.
Arguments
-
id
String
File id to look for.
Adds file to the queue programmatically. Can be native file, instance of Plupload.File, instance of mOxie.File, input[type="file"] element, or array of these. Fires FilesAdded, if any files were added to the queue. Otherwise nothing happens.
Arguments
-
file
plupload.File|mOxie.File|File|Node|Array
File or files to add to the queue. -
[fileName]
String
If specified, will be used as a name for the file
Removes a specific file.
Arguments
-
file
plupload.File|String
File to remove from queue.
Removes part of the queue and returns the files removed. This will also trigger the FilesRemoved and QueueChanged events.
Arguments
-
start
Number
(Optional) Start index to remove from. -
length
Number
(Optional) Lengh of items to remove.
Dispatches the specified event name and it's arguments to all listeners.
Arguments
-
name
String
Event name to fire. -
Multiple
Object..
arguments to pass along to the listener functions.
Check whether uploader has any listeners to the specified event.
Arguments
-
name
String
Event name to check for.
Adds an event listener by name.
Arguments
-
name
String
Event name to listen for. -
func
Function
Function to call ones the event gets fired. -
scope
Object
Optional scope to execute the specified function in.
Removes the specified event listener.
Arguments
-
name
String
Name of event to remove. -
func
Function
Function to remove from listener.
Removes all event listeners.
### [destroy()](/moxiecode/plupload/blob/master/src/plupload.js#L1703 "Defined at: src/plupload.js:1703")Destroys Plupload instance and cleans after itself.
## Events ### InitFires when the current RunTime has been initialized.
### PostInitFires after the init event incase you need to perform actions there.
### RefreshFires when the silverlight/flash or other shim needs to move.
### StateChangedFires when the overall state is being changed for the upload queue.
### UploadFileFires when a file is to be uploaded by the runtime.
### BeforeUploadFires when just before a file is uploaded. This event enables you to override settings on the uploader instance before the file is uploaded.
### QueueChangedFires when the file queue is changed. In other words when files are added/removed to the files array of the uploader instance.
### UploadProgressFires while a file is being uploaded. Use this event to update the current file upload progress.
### FilesRemovedFires while a file was removed from queue.
### FilesAddedFires while when the user selects files to upload.
### FileUploadedFires when a file is successfully uploaded.
### ChunkUploadedFires when file chunk is uploaded.
### UploadCompleteFires when all files in a queue are uploaded.
### ErrorFires when a error occurs.
### DestroyFires when destroy method is called.