Extjs 提交表单时重置文件上载字段
我使用的是ExtJS版本4.1.1 我尝试使用filefield创建上传文件表单,如下所示:Extjs 提交表单时重置文件上载字段,extjs,file-upload,filefield,Extjs,File Upload,Filefield,我使用的是ExtJS版本4.1.1 我尝试使用filefield创建上传文件表单,如下所示: { xtype: 'filefield', itemId : 'my-file', name: 'my file', emptyText : 'No file chosen', fieldLabel: 'Upload File', submitValue: true, allowBlank : false, buttonText: 'Bro
{
xtype: 'filefield',
itemId : 'my-file',
name: 'my file',
emptyText : 'No file chosen',
fieldLabel: 'Upload File',
submitValue: true,
allowBlank : false,
buttonText: 'Browse',
listeners: {
change: function(fld, value) {
var newValue = value.replace(/C:\\fakepath\\/g, '');
fld.setRawValue(newValue);
}
}
}
提交表单时,文件字段
将重置
正如我在书中看到的
我尝试覆盖文件字段
:
Ext.override(Ext.form.field.File, {
extractFileInput: function() {
var me = this,
fileInput = me.fileInputEl.dom,
clone = fileInput.cloneNode(true);
fileInput.parentNode.replaceChild(clone, fileInput);
me.fileInputEl = Ext.get(clone);
me.fileInputEl.on({
scope: me,
change: me.onFileChange
});
return fileInput;
}
当我提交表格时,它看起来不错
我在文本字段中看到的值没有重置为空
但是,当我再次提交表单而不重新选择文件时,发送到服务器的数据为空
应保留发送到服务器的数据
其他信息:
这个问题发生在我使用Chrome和IE时,它在Firefox上似乎可以正常工作
它是否与我在选择文件时在文本字段上看到的C:\\fakepath
有关
如何解决此问题?在
文件字段上设置clearOnSubmit
为false