/**
* 离屏文件选择
*/
const createUpload = (callback: Function) => {
const inputObj = document.createElement('input');
inputObj.setAttribute('type', 'file');
inputObj.setAttribute('name', 'file');
inputObj.setAttribute('accept', '.xlsx,.xls');
inputObj.click();
inputObj.addEventListener('change', (e: any) => {
const file = e.target.files[0]; // 原为e.path[0].files[0],不兼容火狐和safria浏览器
let form = new FormData();
form.append('file', file);
callback(form);
});
};
export default createUpload;