问题描述
我正在尝试使用以下代码上传文件:
window = Ext.create('Ext.window.Window',{
renderTo: Ext.getBody(),bodyPadding: '20 10',title: 'Upload file',autoDestroy: true,hidden: true,modal: true,layout: {
type: 'hbox',align: 'middle',pack: 'center'
},items: [
uploadForm = new Ext.form.Panel({
items: [
file = new Ext.form.field.File({
xtype: 'filefield',name: 'fileName',fieldLabel: 'File',allowBlank: false,buttonText: 'Select file...',})
]
})
],buttons: [{
text: 'Cancel',handler: function () {
upload.hide();
}
},{
text: 'Upload',handler: function () {
var form = uploadForm.getForm();
if (form.isValid()) {
form.submit({
url: 'upload',waitMsg: 'Uploading your file...',scope: this,success: function (form,action) {
upload.close();
var json = JSON.parse(action.response.responseText);
if (json.success) {
Ext.Msg.alert('Success',json.message);
} else {
Ext.Msg.alert('Error',json.message);
}
},failure: function (form,action) {
upload.close();
try {
var json = JSON.parse(action.response.responseText);
Ext.create('Ext.window.MessageBox').show({
title: 'Failure',msg: json.message
});
} catch (err) {
Ext.create('Ext.window.MessageBox')
.alert('Failure','Failed to parse response');
}
}
});
}
}
}]
});
代码在Firefox和Opera中正常工作,并且我成功获得了响应,但是在chrome中检查网络活动时,状态被取消,并且在控制台中我得到了警告:资源被解释为Document,但是以MIME类型application / json。因此,即使文件已上传,提交也总是返回失败。有人可以建议如何解决此问题吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)