# j-DropFiles

> j-DropFiles: singleton; captures all dropped files into the window

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: en
Content-SHA256: 8d44e9b9333463962ac80fae9ad54e6343facd02fc223b621298302d10da2402
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: components@910ed1a86f6e72b4f031d3ad0dc7844f9fc5cb8e
Review: not-recorded

- 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.

```html 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>
```
