1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
Ext.onReady( function () {
Ext.widget( ‘form‘ , {
title: ‘Upload Demo‘ ,
width: 400,
bodyPadding: 10,
items: [{
xtype: ‘filefield‘ ,
name: ‘file‘ ,
fieldLabel: ‘File‘ ,
labelWidth: 50,
anchor: ‘100%‘ ,
buttonText: ‘Select File...‘
}],
buttons: [{
text: ‘Upload‘ ,
handler: function () {
var form = this .up( ‘form‘ ).getForm();
if (form.isValid()) {
form.submit({
url: ‘/extjs-tutorials/upload.php‘ ,
waitMsg: ‘Uploading your file...‘ ,
success: function (f, a) {
var result = a.result, data = result.data,
name = data.name, size = data.size,
message = Ext.String.format( ‘<b>Message:</b> {0}<br>‘ +
‘<b>FileName:</b> {1}<br>‘ +
‘<b>FileSize:</b> {2}‘ ,
result.msg, name, size);
Ext.Msg.alert( ‘Success‘ , message);
},
failure: function (f, a) {
Ext.Msg.alert( ‘Failure‘ , a.result.msg);
}
});
}
}
}],
renderTo: ‘output‘
});
});
|