show-open-file-picker
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

show-open-file-picker

A cross-browser ponyfill or polyfill for showOpenFilePicker() and showSaveFilePicker().

The showOpenFilePicker() method shows a file picker that allows a user to select a file or multiple files and returns a handle for the file(s).

npm install show-open-file-picker

MDN Documentation

Usage

<script src="https://cdn.jsdelivr.net/npm/show-open-file-picker/polyfill.js"></script>

<button id="button">Show Open File Picker</button>

<script>
button.onclick = () => {
  showOpenFilePicker({
    types: [
      {
        description: "Images",
        accept: {
          "image/*": [".png", ".gif", ".jpeg", ".jpg"],
        },
      },
    ],
    excludeAcceptAllOption: true,
    multiple: false,
  })
}
</script>
import { showOpenFilePicker } from 'show-open-file-picker'

button.onclick = () => {
  showOpenFilePicker({
    types: [
      {
        description: "Images",
        accept: {
          "image/*": [".png", ".gif", ".jpeg", ".jpg"],
        },
      },
    ],
    excludeAcceptAllOption: true,
    multiple: false,
  })
}

Package Sidebar

Install

npm i show-open-file-picker

Weekly Downloads

1,195

Version

0.3.0

License

(MIT-0)

Unpacked Size

15.3 kB

Total Files

9

Last publish

Collaborators

  • jonathantneal