var path = '';
var FileReader = window.FileReader;
var clip = document.getElementById('imgContent');
var fileInput = document.getElementById('file');
var fileHandler = function (e) {
if (FileReader) {
var reader = new FileReader();
var file = this.files[0];
reader.onload = function (e) {
clip.setAttribute('src', e.target.result);
console.log('width: ' + (clip.width || clip.naturalWidth));
console.log('height: ' + (clip.height || clip.naturalHeight));
};
reader.readAsDataURL(file);
} else {
path = e.target.value;
if (/"\w\W"/.test(path)) {
path = path.slice(1, -1);
}
clip.setAttribute('src', path);
}
};
fileInput.addEventListener('change', fileHandler, false);