# j-FileReader

> j-FileReader - лесен за използване

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

- Синглът
- Само за текстови файлове

__Методи__:
- `component.open(opt)` - отваряне на файлове браузър
	- `opt.multiple {Boolean}` позволява многобройни файлове (предварително: `false`)
	- `opt.accept {String}` позволява само определен тип съдържание (предварително: `undefined`)
	- `opt.base64 {Boolean}` чете файл в Base64 кодиране (предварително: `false`)
	- __NEW__: `opt.files {HTTP Files}` чете файлове, например от Drag & Drop
	- `opt.callback {Function(file)}` Едно повикване
	- НОВА: `opt.progress {Function(percentage, file)}` опционално

```js
var opt = {};
opt.accept = 'text/*';
// opt.files = e.files;
opt.callback = function(file) {
	console.log(file);
};
SETTER('filereader/open', opt);
```

Използвайте го с `<ui-component name="filereader">`Когато компонентът все още не е зареден, jComponent Изтегляне на първия адрес в `DEF.fallback` (След това Componentator Източник: Питър Шерка Componentator Съставни съставки, лиценз на MIT.

```html example.html
<ui-component name="filereader"></ui-component>
<a href="javascript:fopen()">OPEN FILE</a>

<script>
	function fopen() {
		var opt = {};
		opt.accept = 'text/*';
		opt.callback = function(file) {
			$(document.body).append('<div><pre><code>{0}</code></pre></div>'.format(JSON.stringify(file, null, '    ').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;')));
		};
		SETTER('filereader/open', opt);
	}
</script>
```
