j-FileUploader
A simple component for uploading files. It supports auto-resizing images.
- IMPORTANT: in jComponent v20, the value of
opt.urlmust be in the formPOST /url/
Configuration:
url {String}a default URL address for uploading
Methods:
fileuploader/upload(opt)shows a file dialogopt.url {String}important URL where will be image uploadedopt.callback(response, errors) {Function}a callback importantopt.multiple {Boolean}supports multiple files (default:false)opt.progress(percentage){Function}opt.accept {String}accept type (default:*/*)opt.prefix {String}a name prefix<input name="file{0}"(default:file{0})opt.files {FileList}optional (if you use e.g Drag & Drop)opt.data {Object}optional, additional custom datakey_string:value_stringopt.width {Number}optional, image widthopt.height {Number}optional, image heightopt.background {String}optional, background color defined in HEX or can betransparentopt.keeporiginal {Boolean}optional, prevents for double resizing (default:false)opt.onlylarger {Boolean}optional, resizes images only larger thanopt.widthoropt.heightopt.base64 {String}optional, it can contain a validdataURIformat (required to fillopt.filename)opt.filename {String}optional, required withopt.base64fieldopt.quality {Number}optional, a default JPEG quality (default:90)- NEW:
opt.disproportionate {Boolean}useopt.widthoropt.heightas maximum values
Friendly components:
This component works with loading when the file is uploading.
Use it with <ui-component name="fileuploader">. When the component is not loaded yet, jComponent downloads it on first use from the address in DEF.fallback (the Componentator CDN by default). Author: Peter Širka. Source: the Componentator components repository, MIT license.
<ui-component name="fileuploader"></ui-component>
<div class="exec link" data-exec="upload">Upload</div>
<script>
function upload() {
var opt = {};
opt.url = '/api/upload/';
// jComponent v20:
// opt.url = 'POST /api/upload/';
// opt.multiple = true;
// opt.accept = 'text/*';
opt.callback = function(response, err) {
console.log(response, err);
};
opt.progress = function(percentage) {
console.log(percentage);
};
SETTER('fileuploader/upload', opt);
}
</script>