Elfayer
5 Sep 2012, 4:34 AM
Hi,
I adapted the example usage of : http://docs.sencha.com/ext-js/4-1/#!/api/Ext.form.field.File
Here I am :
Ext.define('EXC.view.uploadWindow', {
extend: 'Ext.window.Window',
alias: 'widget.uploadWindow',
title: 'Upload',
width: 400,
draggable: false,
resizable: false,
items: {
xtype: 'form',
bodyPadding: 10,
frame: true,
items: [{
xtype: 'textfield',
fieldLabel: 'Name',
labelWidth: 50,
allowBlank: false,
anchor: '100%'
}, {
xtype: 'filefield',
fieldLabel: 'File',
labelWidth: 50,
allowBlank: false,
anchor: '100%',
buttonText: 'Browse...'
}],
buttons: [{
text: 'Upload',
handler: function () {
var form = this.up('form').getForm();
if (form.isValid()) {
form.submit({
url: 'file-upload.php',
waitMsg: 'Uploading your file...',
success: function (fp, o) {
Ext.Msg.alert('Success', 'Your file "' + o.result.file + '" has been uploaded.');
}
});
}
}
}]
}
});
But I don't understand the part with the upload button handler. What do I have to put in the "url"? How does that work?
I would like to upload .pdf, .xls, .ppt and .csv files. So I have to add a new file in the file table of my database, but I also need to copy the file uploaded in a directory of the server. How do I do that?
Thanks in advance !
I adapted the example usage of : http://docs.sencha.com/ext-js/4-1/#!/api/Ext.form.field.File
Here I am :
Ext.define('EXC.view.uploadWindow', {
extend: 'Ext.window.Window',
alias: 'widget.uploadWindow',
title: 'Upload',
width: 400,
draggable: false,
resizable: false,
items: {
xtype: 'form',
bodyPadding: 10,
frame: true,
items: [{
xtype: 'textfield',
fieldLabel: 'Name',
labelWidth: 50,
allowBlank: false,
anchor: '100%'
}, {
xtype: 'filefield',
fieldLabel: 'File',
labelWidth: 50,
allowBlank: false,
anchor: '100%',
buttonText: 'Browse...'
}],
buttons: [{
text: 'Upload',
handler: function () {
var form = this.up('form').getForm();
if (form.isValid()) {
form.submit({
url: 'file-upload.php',
waitMsg: 'Uploading your file...',
success: function (fp, o) {
Ext.Msg.alert('Success', 'Your file "' + o.result.file + '" has been uploaded.');
}
});
}
}
}]
}
});
But I don't understand the part with the upload button handler. What do I have to put in the "url"? How does that work?
I would like to upload .pdf, .xls, .ppt and .csv files. So I have to add a new file in the file table of my database, but I also need to copy the file uploaded in a directory of the server. How do I do that?
Thanks in advance !