1.4.1 • Published 4 years ago

mw-file-uploader v1.4.1

Weekly downloads
287
License
ISC
Repository
-
Last release
4 years ago

mw-file-uploader

Dependency-free library for uploading files.

Installation

With npm:

// last stable
npm install mw-file-uploader@1.4.1

Usage

The FileUploader can be bound to an input field:

<input type="field" id="file-uploader">

Import FileUploader

import FileUploader from 'mw-file-uploader'
<input type="file" id="file-uploader">

<script>
let FileUploader = new FileUploader({
    field: document.getElementById('file-uploader')
})
</script>

Configuration

Available options are:

OptionTypeDefaultDescription
fieldHTMLElementnullInput element, requires to have type="file"
acceptstring'' (empty string)One or more unique file type specifiers describing file types to allow, divided by comma. Example: '.jpg,.png'
multiplebooleanfalseEnables adding multiple files.
allowDropbooleanfalseEnables dragging and dropping files to the dropzone element.
dropzoneHTMLElementnull if allowDrop is false. If allowDrop is true and dropzone element has not been defined, FileUploader will create an empty <div> below the input element.Any HTML element where files can be dragged. Only works if allowDrop is true.
onAddFilefunction() => {}Callback function that gets passed an array of the added files
onRemoveFilefunction() => {}Callback function that gets passed an array of the removed files
fieldClassstring'file-uploader-input'Class(es) added to the input field.
dropzoneClassstring'file-uploader-dropzone'Class(es) added to the dropzone element.

Properties

In addition to the options property, FileUploader exposes additional properties:

  • field
  • fileList contains all the added files

Methods

  • add(files)
  • remove(files)
  • open()

License

ISC

1.4.1

4 years ago

1.4.0

4 years ago

1.3.9

4 years ago

1.3.8

4 years ago

1.3.7

5 years ago

1.3.6

5 years ago

1.3.5

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago