ForgeComponents
en

Components

j-DropFiles

jComponent 20 · jcomponent@20 component Example loaded with jComponent 20
  • singleton
  • captures all dropped files into the window
  • must be located under <body> element due to positioning

Configuration:

  • exec {String} a link to the function(files, e)
  • NEW: check {String} optional, a link to the function(e) that must return true (allows drag&drop) or false (disallow)

Use it with <ui-component name="dropfiles">. 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="dropfiles" config="exec:dropfiles" class="hidden">
	Drag &amp; Drop files here
</ui-component>

<script>
	function dropfiles(files, evt) {

		console.log(files, evt);

		/*

		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>