# js-pick-file

> A bare-bones vanilla library to open file picker programatically.

Latest version **1.0.13** (published 2022-07-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install js-pick-file
pnpm add js-pick-file
yarn add js-pick-file
bun add js-pick-file
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.13 |
| Published | 2022-07-21 |
| First published | 2019-10-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Arpit Roopchandani |
| Maintainers | arpit9295 |
| Keywords | file, picker, pick, input, filepicker, promise |

## Links

- npm: https://www.npmjs.com/package/js-pick-file
- Repository: https://github.com/arpit9295/js-pick-file
- Homepage: https://github.com/arpit9295/js-pick-file#readme
- Issues: https://github.com/arpit9295/js-pick-file/issues
- npm.io page: https://npm.io/package/js-pick-file

## Dependencies (1)

- [underscore](https://npm.io/package/underscore.md) ^1.9.1

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 1.0.13 (latest) — 2022-07-21
- 1.0.12 — 2022-07-21
- 1.0.11 — 2020-09-11
- 1.0.10 — 2020-09-11
- 1.0.9 — 2020-09-11
- 1.0.8 — 2019-10-16
- 1.0.7 — 2019-10-16
- 1.0.6 — 2019-10-11
- 1.0.5 — 2019-10-10
- 1.0.4 — 2019-10-08
- 1.0.3 — 2019-10-08
- 1.0.2 — 2019-10-08

## README

# JS Pick File

[![npm](https://img.shields.io/npm/v/js-pick-file.svg)](https://www.npmjs.com/package/js-pick-file)

A bare-bones vanilla library to open file picker programatically.

[Demo](https://codepen.io/arpit9295/full/QWWOogW)

## Install

```
npm install --save js-pick-file
```

## Usage -

```js
import { pickFile } from 'js-pick-file';

async function uploadFile() {
  options = {
    accept: '.jpg, .jpeg, .png',
    multiple: true,
  }

  const filePromise = pickFile(options);

  try {
    const fileList = await filePromise;
    return fileList;
  } catch () {
    console.error('file picker was closed without input');
  }
}
```

`pickFile()` returns a promise that resolves to a [FileList](https://developer.mozilla.org/en-US/docs/Web/API/FileList)

If you see an input box flashing on your system or sudden whitespace issues, you might have to change the default styling for the file input.

```js
import FilePicker from 'js-pick-file';

FilePicker.config.cloakStyle = 'opacity: 0; position: absolute; bottom: 0; z-index: 0';

const filePromise = FilePicker.pick();
```
## Development setup

```
npm install
```

### Compiles and minifies for production
```
npm run build
```

### Lints and fixes files
```
npm run lint
```

## License

[MIT](https://github.com/arpit9295/js-pick-file/blob/master/LICENSE.md)

---
_Source: https://npm.io/package/js-pick-file · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
