file-dialog

WebJar for file-dialog

Лицензия

Лицензия

MIT
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

file-dialog
Последняя версия

Последняя версия

0.0.7
Дата

Дата

Тип

Тип

jar
Описание

Описание

file-dialog
WebJar for file-dialog
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/alnorris/file-dialog

Скачать file-dialog

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/file-dialog/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>file-dialog</artifactId>
    <version>0.0.7</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/file-dialog/
implementation 'org.webjars.npm:file-dialog:0.0.7'
// https://jarcasting.com/artifacts/org.webjars.npm/file-dialog/
implementation ("org.webjars.npm:file-dialog:0.0.7")
'org.webjars.npm:file-dialog:jar:0.0.7'
<dependency org="org.webjars.npm" name="file-dialog" rev="0.0.7">
  <artifact name="file-dialog" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='file-dialog', version='0.0.7')
)
libraryDependencies += "org.webjars.npm" % "file-dialog" % "0.0.7"
[org.webjars.npm/file-dialog "0.0.7"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

Данный проект не имеет модулей.

file-dialog

npm version PRs Welcome

Directly call the file browser dialog from your code, and get back the resulting array of FileList. Handy for when you need to post files via AJAX/Fetch. No more hacky hiding of <input type="file"> elements. Support for Callbacks & Promises!

  • Supports ES6 Modules, CommonJS, AMD, and global
  • Supports selecting multiple files and the file type 'accepts' attribute (see examples below)
  • Support for all major browsers
  • No jQuery needed, tiny (1.25 KB), with no dependencies

alt text

Install

Supports both CommonJS and ES6 Modules

  1. npm install file-dialog
  2. import fileDialog from 'file-dialog' or const fileDialog = require('file-dialog')

Note: If you want to support older browsers make sure you have babel enabled.

Classic <script> includes

  1. Include minified file-dialog.min.js via <script>
  2. Module is binded to the global variable fileDialog

Examples

Get a File via a promise and POST to server via Fetch

fileDialog()
    .then(file => {
        const data = new FormData()
        data.append('file', file[0])
        data.append('imageName', 'flower')

        // Post to server
        fetch('/uploadImage', {
            method: 'POST',
            body: data
        })
    })

Allow user to select only an image file

fileDialog({ accept: 'image/*' })
    .then(files => {
        // files contains an array of FileList
    })

Allow user to select only images or videos

    
fileDialog({ accept: ['image/*', 'video/*'] })
    .then(files => {
        // files contains an array of FileList
    })

Allow user to select multiple image files at once

fileDialog({ multiple: true, accept: 'image/*' })
    .then(files => {
        // files contains an array of FileList
    })

Classic callback version of the above

fileDialog({ multiple: true, accept: 'image/*' }, files => {
    // files contains an array of FileList
})

Версии библиотеки

Версия
0.0.7