Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/justin-m-lacy/filepick
HTML javascript file picker (and optional loader)
https://github.com/justin-m-lacy/filepick
Last synced: 26 days ago
JSON representation
HTML javascript file picker (and optional loader)
- Host: GitHub
- URL: https://github.com/justin-m-lacy/filepick
- Owner: justin-m-lacy
- License: mit
- Created: 2018-12-28T09:13:10.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2018-12-29T03:42:30.000Z (almost 6 years ago)
- Last Synced: 2024-09-26T03:35:06.226Z (about 1 month ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pickfiles
HTML javascript for picking and default loading of files.
Focus is on versatile capabilities rather than a bare minimum file picker.Single or multiple file picks are supported.
FilePicker can be instantiated with an existing HTML element, an options object,
or no parameters.```javascript
import FilePicker from 'pickfiles';let fp = new FilePicker( element, (picked)=>{
});
```
Setting the `FilePicker.readAs` property enables automatic loading for any picked files.
The possible `readAs` options are exported:
```javascript
/**
* Constants for auto-reading file data.
*/
const ReadAs = {ARRAY:'array',
/**
* Exists only for backward-compatibility.
*/
BINARY:'binstring',
DATA_URL:'dataurl',
TEXT:'text'};
```The following events can be subscribed:
```javascriptlet fp = new FilePicker();
fp.on( 'pick', (picked)=>{});
fp.on( 'abort', (picker)=>{});
// called once for each file loaded.
fp.on( 'load', (data)=>{});
// called after all files have loaded.
fp.on('loadend', (datas)=>{});```