File Upload Component
A work in progress HTML file upload with customizable upload backend.
Usage
Register Component
var UploadControllerFactory = require('uploadcontroller');
var UploadController = UploadControllerFactory({
upload: UploadControllerFactory.XHR({
xhrUrl: 'http://localhost/upload.php?filename=$file',
xhrAsFormData: true,
xhrFormDataFileKey: 'file',
xhrMethod: 'POST',
xhrHeaders: {},
xhrCallback: function(xhr) { },
})
upload: function(name, blob, contentType, abort, progress) {
},
valueKey: 'id',
srcKey: 'access_url',
fields: ['id', 'access_url', 'name', 'size']
});
Using it in a Form
<file-picker name="file" desc="Upload File"></file-picker>
Auto-picked file
<file-picker name="file" filename="2.jpg" size="88316" src="https://www.gstatic.com/webp/gallery/2.jpg" value="11" desc="Upload File"></file-picker>
Submitting Form
"valueKey" returned from the upload backend will be submitted in the form with "name" attribute on the element.