1. Create a simple form panel.
Ext.create('Ext.form.Panel', {
title: 'Document Upload',
width: 400,
bodyPadding: 10,
renderTo: Ext.getBody(),
style: 'margin: 50px',
items: [],
buttons: []
});
2. In the panel's items collection add a file field:
Ext.create('Ext.form.Panel', {
...
items: [{
xtype: 'filefield',
name: 'document',
fieldLabel: 'Document',
msgTarget: 'side',
allowBlank: false,
anchor: '100%'
}],
buttons: []
});
3. Add a button to the panel's buttons collection to handle the form submission:
Ext.create('Ext.form.Panel', {
...
buttons: [{
text: 'Upload Document',
handler: function(){
var form = this.up('form').getForm();
if (form.isValid()) {
form.submit({
url: 'upload.php',
waitMsg: 'Uploading...'
});
}
}
}]
});
댓글 없음:
댓글 쓰기