From 1752984be642167449d5753903cb5b8122343e2a Mon Sep 17 00:00:00 2001 From: Arikaim Date: Tue, 17 Mar 2020 17:34:19 +0200 Subject: [PATCH] = --- upload/upload.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/upload/upload.js b/upload/upload.js index 13e87b4..c14a119 100644 --- a/upload/upload.js +++ b/upload/upload.js @@ -8,6 +8,7 @@ function FileUpload(formId, options) { var defaultIdleLabel = "Drag & Drop file or Browse "; + var filepondId; this.registerPlugin = function(plugIn) { if (isEmpty(plugIn) == false && isObject(FilePond) == true) { @@ -17,15 +18,23 @@ function FileUpload(formId, options) { return false; }; + this.reset = function() { + var files = $(filepondId).filepond('getFiles'); + + files.forEach(function(file) { + $(filepondId).filepond('removeFile',file.id); + }); + }; + this.init = function(formId, options) { var maxFiles = getValue('maxFiles',options,1); var idleLabel = getValue('idleLabel',options,defaultIdleLabel); var acceptedFileTypes = getValue('acceptedFileTypes',options,["*"]); var instantUpload = getValue('instantUpload',options,false); var url = getValue('url',options,'/api/storage/admin/upload'); - var formFields = getValue('formFields',options,{}); - var filepondId = getValue('filepondId',options,'#file'); + var formFields = getValue('formFields',options,{}); var allowMultiple = getValue('allowMultiple',options,false); + filepondId = getValue('filepondId',options,'#file'); //File type validatin plugin this.registerPlugin(FilePondPluginFileValidateType);