【发布时间】:2017-09-12 06:32:25
【问题描述】:
我有文件上传控制,我使用它在服务器上上传图像文件。在此操作中,我将提交两次表单。问题是,在提交表单第一次文件上传提交后,在第二次提交时给出 null 值。 让我们看看我的代码如下。
this.userPhoto = new Ext.create('Ext.form.field.File', {
xtype: 'filefield',
padding: '5 5 5',
cls: 'p-photo-upload',
emptyText: 'Photo',
buttonOnly: true,
fieldLabel: fleet.Language.get('_FLEET_USER_USERDETAIL_PHOTO_'),
name: 'photo',
labelWidth: 200,
width: '26%',
msgTarget: 'under',
listeners: {
scope: this,
change: function (t, value) {
var data = {};
data.userPhoto = t.value;
data.imageType = 'userPhoto';
var postdata = Ext.encode(data);
postdata = Base64.encode(postdata);
this.UserDetailform.getForm().submit({
scope: this,
url: FLEET_PROXY_URL + 'index.php?c=user&a=uploadphoto',
params: { postData: postdata },
success: function (form, action) {
this.setLoading(false);
var b = Ext.decode(action.response.responseText);
console.log(b);
if (b && b.data && b.success === "S") {
var img = '<img src="' + FLEET_SERVER_URL + 'images/temporary/' + b.data.photoname + '" />';
this.userimage.setValue(img);
} else {
this.UserDetailform.getForm().findField('photo').markInvalid(fleet.Language.get(b.errors[0].photo));
}
}
});
}
}
});
this.userPhoto 是 Ext.form.field.File 的对象,浏览文件后我通过提交表单上传它(你可以在 this 的监听器 change 事件中看到代码.userPhoto)这个表单提交方法我用于在服务器端保存临时文件。接下来,我将在第二次提交时保存相同的文件和其他用户详细信息,但在第二次提交时,我没有从 This.userPhoto 中得到任何信息。 请参阅下面的屏幕截图,您可以对此有更好的了解。
在图片中你可以看到有BROWSE和SAVE按钮 选择文件后完成第一个表单提交方法,然后单击保存按钮。
【问题讨论】:
标签: javascript html extjs extjs4.2 extjs5