URL to which the request is sent.
If undefined or empty, it is set to the action property of the file upload form if available.
autoUpload:Boolean
To enable automatic uploads, set this option to true.
data:Object
Additional form data to be sent along with the file uploads can be set using this option.
headers:Object
Additional request headers.
multiple:Boolean
It specifies that multiple files can be selected at once, default true.
accept:String
If the value of the type attribute is file, this attribute indicates the types of files that the server accepts;
otherwise it is ignored. The value must be a comma-separated list of unique content type specifiers: image/*, audio/*, video/*, etc.
duplicate:Boolean
The ability to upload duplicates, default false.
paramName:String
The parameter name for the file form data (the request argument name).
If undefined or empty, the name property of the file input field is used, or files[] if the file input name property is also empty.
dataType:String
The type of data that is expected back from the server, default json.
chunkSize:Number
Chunk size in bytes, eg: .5 * FileAPI.MB.
chunkUploadRetry:Number
Number of retries during upload chunks.
maxSize:Number
The maximum allowed file size in bytes, by default unlimited.
maxFiles:Number
This option limits the number of files that are allowed to be uploaded using this plugin.
Filter function of selected files, eg: function (file, info){ return /^image/.test(file.type) && info.width > 320 }.
imageTransform:Object
Rules of changes the original image on the client (see details).
imageTransform: {// resize by max sidemaxWidth: 800,maxHeight: 600}
imageOriginal:Boolean
Sent to the server the original image or not, if defined imageTransform option.
elements:Object
// Default options
elements: {// Controlsctrl: {upload: '[data-fileapi="ctrl.upload"]',reset: '[data-fileapi="ctrl.reset"]',abort: '[data-fileapi="ctrl.abort"]'},// Display element depending on filesempty: {show: '[data-fileapi="empty.show"]',hide: '[data-fileapi="empty.hide"]'},// Display element depending on queue stateemptyQueue: {show: '[data-fileapi="emptyQueue.show"]',hide: '[data-fileapi="emptyQueue.hide"]'},// Display element depending on upload stateactive: {show: '[data-fileapi="active.show"]',hide: '[data-fileapi="active.hide"]'},// Preview file (single upload)preview: {el: 0,// css selectorwidth: 0,height: 0,keepAspectRatio: false// optional: false to stretch cropped image to preview area, true scale image proportionally},// Total size of queuesize: '[data-fileapi="size"]',// Selected file namename: '[data-fileapi="name"]',// Progress bar totalprogress: '[data-fileapi="progress"]',// Filelist optionsfile: {// Templatetpl: '[data-fileapi="file.tpl"]',// Progress barprogress: '[data-fileapi="file.progress"]',// Display element depending on upload stateactive: {show: '[data-fileapi="active.show"]',hide: '[data-fileapi="active.hide"]'},// Preview file or iconpreview: {el: 0,// css selectorget: 0,// eg: function($el, file){ $el.append('<i class="icon icon_'+file.name.split('.').pop()+'"></i>'); }width: 0,height: 0,keepAspectRatio: false// optional: false to stretch cropped image to preview area, true scale image proportionally}},// Drag and dropdnd: {// DropZone: selector or elementel: '[data-fileapi="dnd"]',// Hover classhover: 'dnd_hover'}}
Events
onSelect:Function(evt:$.Event, data:FilesObject)
Retrieve file List, takes two arguments.
$('...').fileapi({onSelect: function(evt,data){data.all;// All filesdata.files;// Correct filesif(data.other.length){// errorsvarerrors=data.other[0].errors;if(errors){errors.maxSize;// File size exceeds the maximum size `@see maxSize`errors.maxFiles;// Number of files selected exceeds the maximum `@see maxFiles`errors.minWidth;// Width of the image is smaller than the specified `@see imageSize`errors.minHeight;errors.maxWidth;// Width of the image greater than the specified `@see imageSize`errors.maxHeight;}}}});
请发表评论