-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Options
- Required Options
-
Filters
-
filters
{}
-
mime_types
[]
-
max_file_size
0 (unlimited)
-
prevent_duplicates
false
-
mime_types
-
filters
-
Control the Request
-
headers
undefined
-
multipart
true
-
multipart_params
undefined
-
max_retries
0
-
headers
-
Chunk Disabled by default
-
chunk_size
0 (disabled)
-
chunk_size
- Client-Side Image Resize Disabled by default
-
Drag'n'Drop Files from the Desktop Disabled by default
-
drop_element
undefined
-
drop_element
-
Useful Options
-
multi_selection
false
-
required_features
undefined
-
unique_names
false
-
multi_selection
-
Optional
-
runtimes
"html5,flash,silverlight,html4"
-
file_data_name
"file"
- container Defaults to a parent node of browse_button
-
flash_swf_url
"js/Moxie.swf"
-
silverlight_xap_url
js/Moxie.xap
-
runtimes
Almost any DOM element can be turned into a file dialog trigger, but usually it is either a button, actual file input or an image. Value for the option can be either a DOM element itself or it's id.
### url _Required_Url of the server-side upload handler that will accept the files, do some security checks and finally move them to a destination folder. Might be relative or absolute.
## Filters ### filters _Default:_ `{}`Plupload comes with several built-in filters that provide a way to restrict a selection (or perhaps an upload) of files that do not meet specific requirements. These are:
It is also possible to define custom file filters.
### filters.mime_types _Default:_ `[]`By default any file type can be picked from file selection dialog (which is obviously a rarely desired case), so by supplying a mime_types
filter one can constrain it to only specific file types.
For example to allow only images and zip archives:
filters: {
mime_types : [
{ title : "Image files", extensions : "jpg,gif,png" },
{ title : "Zip files", extensions : "zip" }
]
}
title
property will be used as a title for the filter, where supported.
Official format for the accept attribute, where one can supply comma-separated list of mime types, is also supported (but the former one is recommended):
filters: {
mime_types : "image/*,application/zip"
}
Unfortunately browsers do not always interpret this option consistently (especially in html5
runtime). For example, no matter what, Firefox will still allow to select any file type by default and optionally provide a file filters at the bottom of the selection dialog. In addition to this there are differences in the interpretation of the accept attribute of input[type="file"]
itself, for more information check: "Although I specify file extension in filters, I still cannot pick it up in file dialog or drag and drop, why?" entry from our FAQ.
Default: 0 (unlimited)
By default, file of any size is allowed to the queue. But it is possible to constrain it from the top with the max_file_size
filter. It accepts numeric or formatted string values, e.g.: 204800
or "204800b"
or "200kb"
.
If violated, triggers Error
event with the code of plupload.FILE_SIZE_ERROR
.
Default: false
If set to true
the Plupload will not allow duplicates. Duplicates are detected by matching file's name and size.
If violated, triggers Error
event with the code of plupload.FILE_DUPLICATE_ERROR
.
A way to pass custom HTTP headers with each upload request. The option is simple set of key/value pairs of header names and their values.
- Not supported by
html4
runtime. - Requires special operational mode in case of
flash
andsilverlight
runtimes.
Whether to send the file as multipart/form-data (default) or binary stream. The latter case is not supported by html4
and is a bit troublesome in flash
runtime. It also requires a special care on server-side. Here's an excerpt from our bundled upload.php
for example:
<?php
...
if (!$in = @fopen("php://input", "rb")) {
die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
}
...
- Not supported by
html4
runtime. flash
runtime requires the file to be read in memory first.
Additional multipart fields to be passed along with each upload request. Each field can be represented by simple key/value pair or some nested arrays and/or objects. For example:
multipart_params: {
one: '1',
two: '2',
three: '3',
object: {
four: '4',
five: '5'
},
array: ['6', '7', '8']
}
Default: 0 (no retries)
If max_retries
is greater than 0
, upload will be retried that many times every time there is plupload.HTTP_ERROR
detetcted. Be it complete file or a single chunk.
For more information see: "When to use chunking and when not?" from our FAQ.
## Useful Options ### multi_selection _Default_: `false`By default, Plupload lets you select only one file from the browse dialog at a time. Setting multi_selection
to true
, will allow you to select multiple.
However, this option is not compatible with html4
runtime and will effectively exclude it from the list of potential runtime candidates (even if it is in the list, it will not be used).