npm.io
0.2.1 • Published 8 years ago

drop-upload

Licence
MIT
Version
0.2.1
Deps
0
Size
26 kB
Vulns
0
Weekly
0

Drop Upload

Small JavaScript library to allow dropping files in textarea.

Installation

Via npm:

$ npm install --save drop-upload

Via bower:

$ bower install jquery-miller-columns

Manual installation:

Download the latest release.

Via CDN:

<script src="//cdn.jsdelivr.net/npm/drop-upload/dist/drop-upload.min.js"></script>

Dependecies

No dependency.

Usage

Call on the desired element:

// DropUpload([parentSelector], [childSelector], [options]); eg:
DropUpload(document, 'textarea.uploadable-textarea');

First argument is the propagated target, second is the target selector (like in jQuery $(document).on('event', '.uploadable-textarea', function() {...})), third is the options.

API reference

Options
Key Default value Description
uploadPath /upload Path to upload
uploadKey file Key of the file in upload content
uploadingCallback function (fileName) {...} The value in the textarea during upload
uploadedCallback function (fileName, path) {...} The value in the textarea after upload
decodeResponseCallback function (response) {...} Decoding response
timeout 0 Timeout for requests (in ms)
Events
Event name Description
drop-upload:start Upload started
drop-upload:end Upload ended
drop-upload:success Upload ended with success
drop-upload:error Upload failed
drop-upload:timeout Upload failed with timeout

License

This project is under MIT License.

Keywords