The environment and version of this article
- Spring Boot 2.5.0
- Ext JS 7.0.0
front-end code
Place a field of type fileuploadfield in the Form, and set the value of the name attribute. This value will be used as the parameter name of the backend. The sample code is as follows:
[{
xtype: 'form',
title: '上传文件',
width: 400,
bodyPadding: 10,
items: [{
xtype: 'fileuploadfield',
name: 'myfile',
fieldLabel: '文件',
labelWidth: 50,
allowBlank: false,
buttonText: '选择文件...'
}],
tbar:[{
text:'上传',
handler: function () {
var form = this.up('form').getForm();
var url = 'http://localhost:8080/extjs/files/upload';
if (form.isValid()) {
form.submit({
url: url,
waitMsg: 'Uploading your file...',