ForgeComponenti
it

Componenti

j-Upload

jComponent 20 · jcomponent@20 component Esempio caricato con jComponent 20

Il componente può eseguire upload dei file.

  • Facile e universale utilizzo
  • singolo

Metodi:

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);

I file vengono caricati con questi nomi/chiari nel modulo file1, file2, file..N.

Utilizzare con <ui-component name="upload">Quando il componente non è ancora caricato, jComponent Scarica il codice in prima utilizzazione dall'indirizzo DEF.fallback (Il Componentator La storia di Peter Širka.Fonte: il Componentator Ristorante dei componenti, licenza 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>