New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

create-file-input

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-file-input

> 无论是否选择了文件, 关闭后自动移除 input element

  • 1.0.9
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
20
Maintainers
1
Weekly downloads
 
Created
Source

快速打开文件选择窗口

无论是否选择了文件, 关闭后自动移除 input element

Installtion
npm i create-file-input
# or
yarn add create-file-input
Usage
import createFileInput from 'create-file-input'

// 基础使用
createFileInput({
  onChange: e => {
    const file = e.target.files[0]
    const formData = new FormData()
    formData.append('file', file)
  }
})

// 开启只要附件数据
createFileInput({
  fileOnly: true,
  onChange: file => {
    const formData = new FormData()
    formData.append('file', file)
  }
})

// 开启只要附件数据
createFileInput({
  fileOnly: true,
  multiple: true,
  onChange: files => {
    formData.append('file', files[0])
  }
})
Props
参数名说明默认值
accept允许选择的文件类型*
multiple是否多选false
fileOnly选择后的回调是否只需要文件数据false
onChange选择后的回调-

Keywords

FAQs

Package last updated on 11 Apr 2023

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