1.0.13 • Published 2 years ago

js-pick-file v1.0.13

Weekly downloads
19
License
MIT
Repository
github
Last release
2 years ago

JS Pick File

npm

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

Demo

Install

npm install --save js-pick-file

Usage -

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

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.

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

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago