vendredi 4 juillet 2014

ExtjsFileUpload

hi all, i'm junior java developer and i have task with file uploading. So the question is how can i upload files dinamically without submit?(button)

at now i'm using sth like this :



Code:



var uploadButton = Ext.create('Ext.Button', {
ui: 'primary-small',
style: 'margin-left:120px;',
handler: function () {
if (form.isValid()) {
//if(form.)
form.submit({
url: '',
method: 'POST',
success: function (form, response) {
debugger;
console.log(response);
if (!Ext.isEmpty(response) && !Ext.isEmpty(response.response.responseText)) {
var result = Ext.decode(response.response.responseText);
debugger;
result.files.forEach(function (file) {
console.log(file.name);
debugger;
if (file.name != null && file.name != '') {
me.filesStore.add({
fileName: file.name,
fileId: file.id
});
}
});
}
},
failure: function (form, response) {
debugger;
...
}
})
}


}
});

var form = Ext.create('Ext.form.Panel', { flex: 1,
layout: {
type: 'hbox',
align: 'stretch'},
items: [
{
xtype: 'filefield',
name: 'file',
//buttonOnly: true,
isFileUpload:true,
allowBlank: false,
buttonConfig: {
ui: 'primary-small'
},
msgTarget: 'under',
listeners: {
change: function (fld, value) {
var newValue = value.replace(/C:\\fakepath\\/g, '');
fld.setRawValue(newValue);


},
afterrender: function (cmp) {
cmp.fileInputEl.set({
multiple: 'multiple'
});
}
}
},
uploadButton
]
});



but it is not allowable, i need to add files immediately after choose dialog

Thanks





Aucun commentaire:

Enregistrer un commentaire