diff options
Diffstat (limited to 'vnfmarket/src/main/webapp/vnfmarket/common/directives/fileupload/fileuploadDirective.js')
-rw-r--r-- | vnfmarket/src/main/webapp/vnfmarket/common/directives/fileupload/fileuploadDirective.js | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/vnfmarket/src/main/webapp/vnfmarket/common/directives/fileupload/fileuploadDirective.js b/vnfmarket/src/main/webapp/vnfmarket/common/directives/fileupload/fileuploadDirective.js index 3f64841d..43137a5a 100644 --- a/vnfmarket/src/main/webapp/vnfmarket/common/directives/fileupload/fileuploadDirective.js +++ b/vnfmarket/src/main/webapp/vnfmarket/common/directives/fileupload/fileuploadDirective.js @@ -43,7 +43,15 @@ function link(scope, element, attrs) { element.bind("change", function (changeEvent) { scope.$apply(function () { - scope.fileUpload = changeEvent.target.files[0]; + var fileType = changeEvent.target.accept; + var ext = "." + changeEvent.target.value.match(/\.(.+)$/)[1]; + scope.fileUpload = null; + if (typeof fileType == undefined || fileType == "") { + scope.fileUpload = changeEvent.target.files[0]; + } + else if ((Array.isArray(fileType) && fileType.indexOf(ext) > -1) || (fileType == ext)) { + scope.fileUpload = changeEvent.target.files[0]; + } }); }); } |