ForgeComponents
en

Components

j-DragDropFiles

jComponent 20 · jcomponent@20 component Example loaded with jComponent 20

Configuration:

  • exec {String} - the component executes this method if the files are dropped
  • class {String} - toggles class if the drag over is emitted
  • click {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 to application/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.

example.html
<ui-component name="dragdropfiles" path="null" config="exec:dragdropfiles_files;accept:application/pdf;">
	<span>Drag &amp; 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>