| repo | url | homepage | starredAt | createdAt | updatedAt | language | license | branch | stars | isPublic | isTemplate | isArchived | isFork | hasReadMe | refreshedAt | description | tags |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
tschoffelen/pick-a-file |
2024-09-16T22:27:23Z |
2024-08-21T17:26:16Z |
2024-09-16T22:27:23Z |
JavaScript |
MIT |
main |
1 |
true |
false |
false |
false |
true |
2025-02-25T19:59:21.528Z |
JS helper to ask the user to pick a file. |
Ask the user to pick a file, get a promise with a File back.
Does this need to be a package? No, probably not, you might as well copy and paste the code from
index.js into your project. But I kept re-writing this little snippet, and I
thought I'd just make it easy for myself to access it.
Run yarn add pick-a-file, or npm i pick-a-file if you insist.
import pickFile from 'pick-a-file';
const file = await pickFile({
accept: ".csv",
});
if (file) {
console.log(`Nice, you selected a file: ${file.name}`);
} else {
console.log(`Boohoo, why did you not select a file?!`);
}Options: