gpt4 book ai didi

javascript - Ext JS 无法获取要上传的文件

转载 作者:行者123 更新时间:2023-11-28 20:39:02 25 4
gpt4 key购买 nike

我正在使用 Ext JS 3.4,但在从表单上传文件时遇到问题PHP 脚本无法接收文件数据(即使尝试使用 print_r($_FILES) 也应该显示收到的任何文件或错误)。

这是我的代码

var editOrganisationForm = new Ext.FormPanel({
url: 'appsrv/users_json.php',
labelWidth: 75,
border:false,
width: 350,
items: {
xtype:'tabpanel',
layoutOnTabChange: true,
deferredRender:true,
border: false,
activeTab: 0,
defaults: {autoHeight:true, bodyStyle:'padding:10px; border: 0', bodyBorder: false},
items:[{
title:'Organisation Info',
layout: 'form',
fileUpload: true,
defaults: {width: 230},
defaultType: 'textfield',
items: [
{xtype: 'hidden', name: 'id'},
{fieldLabel: 'Organisation', name: 'organisation', allowBlank:false},
{
fieldLabel: 'Logo',
name: 'org_logo',
id: 'org_logo',
inputType: 'file',
allowBlank:true
},
{
fieldLabel: 'Theme',
name: 'org_theme',
id: 'org_theme',
store: [['val1', 'First Value'], ['val2', 'Second Value']],
xtype: 'combo',
allowBlank: false,
forceSelection: true,
valueField:'id',
displayField:'name'
}
]
}]
}
});

var winOrg = new Ext.Window({
title: 'Edit Organisation',
layout:'fit',
width:400,
height:215,
closeAction: 'hide',
plain: false,
modal: true,
shadow: true,
items: [editOrganisationForm],
buttons: [{
text:'Save',
handler: function() {
editOrganisationForm.getForm().submit({
method: 'POST',
waitTitle: 'Please Wait...',
waitMsg: 'Saving Changes',
url: 'appsrv/users_json.php',
params: {cmd: "addOrg"},
success: function() {
Ext.Msg.alert('Complete','Your changes have been saved');
tree.root.reload();
winOrg.hide();
},
failure: function(form, action) {
if (action.failureType == 'server') {
obj = Ext.util.JSON.decode(action.response.responseText);
Ext.Msg.alert('Oops!', obj.errors.reason);
} else if (action.failureType == 'client') {
Ext.Msg.alert('Sorry', 'Please ensure all required fields have been completed');
} else {
Ext.Msg.alert('Sorry','An error occurred');
}
}
});
},
disabled: false
}]
});

最佳答案

这就是我解决的问题fileUpload: true 是正确的,但我把它放在了错误的对象中,它应该在表单配置对象中,而不是在表单>面板>项目对象中

关于javascript - Ext JS 无法获取要上传的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14747169/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com