Check files uploaded by user

This commit is contained in:
Ningxin Hu 2017-09-27 16:43:25 +08:00
parent 18c1e32047
commit 2fd0229493

View File

@ -98,8 +98,11 @@ function Utils(errorOutputId) { // eslint-disable-line no-unused-vars
this.addFileInputHandler = function(fileInputId, canvasId) {
let inputElement = document.getElementById(fileInputId);
inputElement.addEventListener('change', (e) => {
let imgUrl = URL.createObjectURL(e.target.files[0]);
self.loadImageToCanvas(imgUrl, canvasId);
let files = e.target.files;
if (files.length > 0) {
let imgUrl = URL.createObjectURL(files[0]);
self.loadImageToCanvas(imgUrl, canvasId);
}
}, false);
};