ForgeKomponenty
sk

Komponenty

j-Upload

jComponent 20 · jcomponent@20 component Príklad načítaný s jComponent 20

Komponent môže vykonávať nahrávanie súborov.

  • jednoduché a univerzálne použitie
  • singleton

Metódy:

var opt = {};

// Restricts files according to the content-type
// opt.accept = 'image/*';

// Enables multiple files
// opt.multiple = true;

// IMPORTANT:
// URL address for uploading
opt.url = '/api/upload/';

// A callback
opt.callback = function(response) {

};

opt.error = function(err) {
	// Optional
	// Error handling
};

// Optional, additional request data
opt.data = {};
opt.data.fieldName1 = 'value';
opt.data.fieldName2 = 'value';

// Shows file browser
SETTER('upload/show', opt);

Súbory sa nahrávajú s týmito menami/kľúčmi v tvare file1, file2, file..N.

Použite ho so <ui-component name="upload">. Keď komponent ešte nie je načítaný, jComponent ho stiahne pri prvom použití z adresy v DEF.fallback (predvolene CDN Componentator). Autor: Peter Širka. Zdroj: úložisko komponentov Componentator, licencia MIT.

example.html
<ui-component name="upload"></ui-component>
<br />
<a href="javascript:uploadfile()">Upload file</a>

<script>
	function uploadfile() {

		var opt = {};

		opt.url = '/api/upload/files/';
		opt.accept = 'image/*';
		opt.multiple = true;
		opt.callback = function(response) {
			console.log(response);
		};
		// opt.error = function(err) {};

        SETTER('upload/show', opt);
    }
</script>