const uploadFile = (extension) =>
  new Promise((resolve, reject) => {
    const fileInput = document.createElement('input');
    fileInput.type = 'file';
    fileInput.style.display = 'none'
    fileInput.accept = extension;
    fileInput.onchange = ()=> {
      if (fileInput.files) {
        resolve(fileInput.files[0]);
        fileInput.remove()
      }
    };
    document.body.appendChild(fileInput);
    fileInput.click();
  });

export { uploadFile }
