# j-DragDropFiles

> j-DragDropFiles options: exec, class, click, accept

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

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

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