我想要一个只有一个按钮“上传按钮”的文件上传功能,点击后会打开文件选择器,如果选择了文件,则必须上传文件。
视图不应显示
我知道使用jQuery或JavaScript很容易实现,但由于我相对较新于Extjs,所以在这里寻求您的帮助。
下面是文档中的示例文件上传程序。如何自定义以适应我的需求:
视图不应显示
input[type=file]
或任何其他标签,而只需一个按钮。我知道使用jQuery或JavaScript很容易实现,但由于我相对较新于Extjs,所以在这里寻求您的帮助。
下面是文档中的示例文件上传程序。如何自定义以适应我的需求:
Ext.create('Ext.form.Panel', {
title: 'Upload a Photo',
width: 400,
bodyPadding: 10,
frame: true,
renderTo: Ext.getBody(),
items: [{
xtype: 'filefield',
name: 'photo',
fieldLabel: 'Photo',
labelWidth: 50,
msgTarget: 'side',
allowBlank: false,
anchor: '100%',
buttonText: 'Select Photo...'
}],
buttons: [{
text: 'Upload',
handler: function() {
var form = this.up('form').getForm();
if(form.isValid()){
form.submit({
url: 'photo-upload.php',
waitMsg: 'Uploading your photo...',
success: function(fp, o) {
Ext.Msg.alert('Success', 'Your photo "' + o.result.file + '" has been uploaded.');
}
});
}
}
}]
});