Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

452 B
Raw Blame
export async function promptUploadFiles({
  acceptedTypes,
}: {
  acceptedTypes?: string;
} = {}): Promise<{ files: File[] }> {
  return new Promise((resolve) => {
    const input = document.createElement('input');
    input.type = 'file';
    input.multiple = true;

    if (acceptedTypes) {
      input.accept = acceptedTypes;
    }

    input.onchange = () => {
      resolve({ files: [...(input.files ?? [])] });
    };

    input.click();
  });
}