j-DragDropFiles
Configuration:
exec {String}- the component executes this method if the files are droppedclass {String}- toggles class if the drag over is emittedclick {Boolean}- causes open file dialog when the user click on the element (default:true)accept {String}- change accept attribute, e.g to only accept pdfs set toapplication/pdf(default:*/*)
Use it with <ui-component name="dragdropfiles">. 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="dragdropfiles" path="null" config="exec:dragdropfiles_files;accept:application/pdf;">
<span>Drag & Drop files here</span>
</ui-component>
<script>
function dragdropfiles_files(files, evt) {
console.log(files);
/*
var data = new FormData();
for (var i = 0, length = files.length; i < length; i++)
data.append('file' + i, files[i]);
UPLOAD('/api/upload/', data, function(response) {
console.log(response);
});
*/
}
</script>