Php 访问JSON编码数据中的上载文件
我已经将表单数据编码为JSON。通过以下ExtJS存储配置实现了这一点:Php 访问JSON编码数据中的上载文件,php,extjs4,Php,Extjs4,我已经将表单数据编码为JSON。通过以下ExtJS存储配置实现了这一点: Ext.define('XXX.store.Registration', { extend: 'Ext.data.Store', model: 'XXX.model.Registration', autoLoad: true, pageSize: 15, autoLoad: { start: 0, limit: 15 }, proxy
Ext.define('XXX.store.Registration', {
extend: 'Ext.data.Store',
model: 'XXX.model.Registration',
autoLoad: true,
pageSize: 15,
autoLoad: {
start: 0,
limit: 15
},
proxy: {
type: 'ajax',
api: {
create: './server/registration/create.php',
read: './server/registration/get.php',
update: './server/registration/update.php',
destroy: './server/registration/destroy.php'
},
reader: {
type: 'json',
root: 'registrations',
successProperty: 'success'
},
writer: {
type: 'json',
writeAllFields: true,
encode: true,
root: 'registrations'
}
}
});
我的服务器端代码已经在PHP中实现。我可以使用字段名作为键访问编码表单字段,如下所示:
$reg = $_REQUEST['registrations'];
$data = json_decode(stripslashes($reg));
$registerNum = $data->registerNum;
$folioNum = $data->folioNum;
我表单中的一个字段是
fileuploadfield
。如何从上传的JSON访问上传的文件。非常感谢您的帮助。文件无法通过ajax上传。标准的解决方法是构建一个隐藏的iframe,然后从那里进行正常的“post”上传。我不确定您是否可以使用ajax访问fileuploadfield。我尝试过使用Ext3.x,但它无法使用。我通常使用表单中的submit函数访问filuploadfield,而不使用ajax。CMIIWThanks负载。如果可能,发布一个解决方法的示例。另外,是否可以更改writer
配置中的type
选项以允许文件上载?对于ExtJs,您可以参考此链接,对于后端,您可以根据需要使用PHP搜索有关上载文件的教程:)