- Notifications
You must be signed in to change notification settings - Fork 1.1k
Module API
İsmail Arılık edited this page Nov 14, 2017 · 5 revisions
- nv-file-drop
<!-- minimal --><elementnv-file-dropuploader="{FileUploader}"></element><!-- maximal --><elementnv-file-dropuploader="{FileUploader}" options="{Object}" filters="{String}"></element>The attribute uploader must be a instance of FileUploader.
The attribute options may be a {FileItem} options or custom properties.
The attribute filters may be {String} that contains filter names separated by ,. For example: 'filterName1, filterName2'. These filters must be predefined:
uploader.filters.push({name:'filterName1',fn:function(){/* your code here */}});uploader.filters.push({name:'filterName2',fn:function(){/* your code here */}});- nv-file-select
<!-- minimal --><inputtype="file" nv-file-selectuploader="{FileUploader}"/><!-- maximal --><inputtype="file" nv-file-selectuploader="{FileUploader}" options="{Object}" filters="{String}"/>- nv-file-over
<!-- minimal --><elementnv-file-overuploader="{FileUploader}"></element><!-- maximal --><elementnv-file-overuploader="{FileUploader}" over-class="{String}"></element>- FileUploader
- url
{String}: Path on the server to upload files - alias
{String}: Name of the field which will contain the file, default isfile - queue
{Array}: Items to be uploaded - progress
{Number}: Upload queue progress percentage. Read only. - headers
{Object}: Headers to be sent along with the files. HTML5 browsers only. - formData
{Array}: Data to be sent along with the files - filters
{Array}: Filters to be applied to the files before adding them to the queue. If the filter returnstruethe file will be added to the queue - autoUpload
{Boolean}: Automatically upload files after adding them to the queue - method
{String}: It's a request method. By defaultPOST. HTML5 browsers only. - removeAfterUpload
{Boolean}: Remove files from the queue after uploading - isHTML5
{Boolean}:trueif uploader is html5-uploader. Read only. - isUploading
{Boolean}:trueif an upload is in progress. Read only. - queueLimit
{Number}: maximum count of files - withCredentials
{Boolean}: enable CORS. HTML5 browsers only.
- addToQueue
function(files[, options[, filters]]){: Add items to the queue, wherefilesis a{FileList|File|HTMLInputElement},optionsis an{Object}andfiltersis a{String}. - removeFromQueue
function(value){: Remove an item from the queue, wherevalueis{FileItem}or index of item. - clearQueue
function(){: Removes all elements from the queue. - uploadItem
function(value){: Uploads an item, wherevalueis{FileItem}or index of item. - cancelItem
function(value){: Cancels uploading of item, wherevalueis{FileItem}or index of item. - uploadAll
function(){: Upload all pending items on the queue. - cancelAll
function(){: Cancels all current uploads. - destroy
function(){: Destroys a uploader. - isFile
function(value){return{Boolean}}: Returns true if value is{File}. - isFileLikeObject
function(value){return{Boolean}}: Returns true if value is{FileLikeObject}. - getIndexOfItem
function({FileItem}){return{Number}}: Returns the index of the{FileItem}queue element. - getReadyItems
function(){return{Array.<FileItems>}}: Return items are ready to upload. - getNotUploadedItems
function(){return{Array.<FileItems>}}: Return an array of all pending items on the queue
- onAfterAddingFile
function(item){: Fires after adding a single file to the queue. - onWhenAddingFileFailed
function(item, filter, options){: When adding a file failed. - onAfterAddingAll
function(addedItems){: Fires after adding all the dragged or selected files to the queue. - onBeforeUploadItem
function(item){: Fires before uploading an item. - onProgressItem
function(item, progress){: On file upload progress. - onSuccessItem
function(item, response, status, headers){: On file successfully uploaded - onErrorItem
function(item, response, status, headers){: On upload error - onCancelItem
function(item, response, status, headers){- On cancel uploading - onCompleteItem
function(item, response, status, headers){: On file upload complete (independently of the sucess of the operation) - onProgressAll
function(progress){: On upload queue progress - onCompleteAll
function(){: On all loaded when uploading an entire queue, or on file loaded when uploading a single independent file
- url
{String}: Path on the server in which this file will be uploaded - alias
{String}: Name of the field which will contain the file, default isfile - headers
{Object}: Headers to be sent along with this file. HTML5 browsers only. - formData
{Array}: Data to be sent along with this file - method
{String}: It's a request method. By defaultPOST. HTML5 browsers only. - withCredentials
{Boolean}: enable CORS. HTML5 browsers only. - removeAfterUpload
{Boolean}: Remove this file from the queue after uploading - index
{Number}- A sequence number upload. Read only. - progress
{Number}: File upload progress percentage. Read only. - isReady
{Boolean}- File is ready to upload. Read only. - isUploading
{Boolean}:trueif the file is being uploaded. Read only. - isUploaded
{Boolean}:trueif the file was uploaded. Read only. - isSuccess
{Boolean}:trueif the file was uploaded successfully. Read only. - isCancel
{Boolean}:trueif uploading was canceled. Read only. - isError
{Boolean}-trueif occurred error while file uploading. Read only. - uploader
{Object}: Reference to the parentUploaderobject for this file. Read only.
- remove
function(){: Remove this file from the queue - upload
function(){: Upload this file - cancel
function(){: Cancels uploading of this file
- onBeforeUpload
function(){: Fires before uploading an item. - onProgress
function(progress){: On file upload progress. - onSuccess
function(response, status, headers){: On file successfully uploaded - onError
function(response, status, headers){: On upload error - onCancel
function(response, status, headers){- On cancel uploading - onComplete
function(response, status, headers){: On file upload complete (independently of the success of the operation)
varuploader=newFileUploader({filters: [{name: 'yourName1',// A user-defined filterfn: function(item){returntrue;}}]});// Another user-defined filteruploader.filters.push({name: 'yourName2',fn: function(item){returntrue;}});- folder
- queueLimit