图片上传code
const uploadBtn = document.querySelector('#upload_btn');
const file = document.querySelector('#upload_file');
uploadBtn.addEventListener('click', function(e) {
var evt = new MouseEvent('click', {
bubbles: false,
cancelable: true,
view: window
});
file.dispatchEvent(evt);
}, false);
file.addEventListener('change', function(e) {
let name = e.target.files[0].name;
console.log(URL.createObjectURL(event.target.files[0]));
let img = new Image();
img.src = URL.createObjectURL(event.target.files[0]);
img.onload = function () {
console.log('图片高:'+this.height+'图片宽:'+this.width)
}
}, false);