我有一个简单的 ExtJs 表单面板,其中包含一个文件上传字段。当我将表单提交到服务器时,所有键值表单值都会发送到服务器,但不会发送文件上传字段的键值对。有人知道为什么吗?(我在下面附上了一些代码片段)
另外我如何处理服务器上的上传。即我想将图像上传到服务器处理它并将其保存在服务器上的某个位置?
public JsonResult SetEmployeeDetails(string firstname, string photopath)
{
GetData data = delegate
{
return Repo.SetEmployeeDetails(firstname, photopath);
};
JsonResultBase jsonResult = GetJsonResult(data);
JsonResult json = PortalJsonResult(jsonResult, JsonRequestBehavior.AllowGet);
return json;
}
xtype: 'form',
title: 'Employee Setup',
items: [{
fieldLabel: 'Firstname',
xtype: 'textfield',
name: 'firstname',
maxLength: 10,
allowBlank:false
},
{
xtype: 'fileuploadfield',
id: 'form-file',
emptyText: 'Select an image',
fieldLabel: 'Photo',
name: 'photopath',
buttonText: '',
buttonCfg: {
iconCls: 'upload-icon'
}
}],
buttons: [{
text: 'Save',
scope: this,
handler: function(){
var form = this.items.items[0].getForm();
if(form.isValid()){
form.submit({
url: 'EmployeeDetails/SetEmployeeDetails',
waitMsg: 'Saving your details...',
success: function(fp, o){
msg('Success', 'Processed file on the server');
}
});
}
}
}]