Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

file-select-dialog

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

file-select-dialog

Call file select dialog programmatically

  • 1.5.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
781
decreased by-9.82%
Maintainers
1
Weekly downloads
 
Created
Source

file-select-dialog

npm version size size codecov code style: prettier Commitizen friendly semantic-release MIT License

Directly call file select dialog to JavaScript. Get Back Promise File or FileList object. No more hacky hiding of <input type="file"> elements.

:sparkles: Feature

  • Supports ES6 Modules
  • Pure Typescript
  • Promise
  • No dependencies, Optimization, Super slim size
  • Modern browser support only
  • Supports selecting multiple files and the file type accepts

:truck: Install

yarn add file-select-dialog
or
npm i file-select-dialog

import like this.

import { fileDialog } from 'file-select-dialog'

:page_facing_up: Docs

Reference is here.

:pencil2: Argument

Parameters Object

keytypedefault
accept(string | stirng[] )?'*'
multipleboolean?false
strictboolean?false

:mag: Examples

Demo

screenshot

By default can only select a single file and get a FileList object.

const onClick = async () => {
  // open file select dialog and waiting user selection then return FileList object.
  const fileList = await fileDialog()
}

If the multiple parameter is true, can select multiple files and get a FileList object.

const onClick = async () => {
  const fileList = await fileDialog({ multiple: true })
}

The accept parameter limit the selecable file types.

const onClick = async () => {
  const fileList = await fileDialog({ accept: '.png' })

  // multiple acceptable types
  const fileList = await fileDialog({ accept: ['.jpg', '.pdf'] })
}

:zap: Advanced

If the parameter of multiple is false and strict is true, can get File object directly. Your editor suggest File object types.

const onClick = async () => {
  const file = await fileDialog({ strict: true })
}

:bulb: LICENSE

MIT



Keywords

FAQs

Package last updated on 29 Nov 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc