Javascript uppy如何将元字段从仪表板添加到XHRUpload
我用 服务器端的Symfony和我面临一些问题,Javascript uppy如何将元字段从仪表板添加到XHRUpload,javascript,php,uppy,Javascript,Php,Uppy,我用 服务器端的Symfony和我面临一些问题,元字段不存在于服务器的元数据文件中 我遵循了doc的例子。我的仪表板包含用于文件、名称和标题的元字段,但当XHRUpload将请求发送到服务器时,我在服务器中的请求中对该键一无所知。我添加了metaFields:null,就像在doc中一样-将其设置为null(默认值)以发送所有元数据字段。,但在服务器中,该键为空,只有文件,id和实体 如何将元字段从仪表板添加到XHRUpload "@uppy/core": "^1.
元字段
不存在于服务器的元数据文件中
我遵循了doc的例子。我的仪表板包含用于文件、名称和标题的元字段,但当XHRUpload
将请求发送到服务器时,我在服务器中的请求中对该键一无所知。我添加了metaFields:null,就像在doc中一样-将其设置为null(默认值)以发送所有元数据字段。
,但在服务器中,该键为空,只有文件
,id
和实体
如何将元字段
从仪表板添加到XHRUpload
"@uppy/core": "^1.13.2",
"@uppy/dashboard": "^1.12.8",
"@uppy/xhr-upload": "^1.6.4",
这是我在浏览器中的请求
// Import the plugins
const Uppy = require('@uppy/core')
const XHRUpload = require('@uppy/xhr-upload')
const Dashboard = require('@uppy/dashboard')
let timeOfLastAttach = new Date();
const uppy = Uppy({
debug: true,
autoProceed: false,
restrictions: {
maxFileSize: 100097152,//100Mb
}
});
uppy.use(Dashboard, {
trigger: '.UppyModalOpenerBtn',
inline: true,
target: '.DashboardContainer',
replaceTargetContent: true,
showProgressDetails: true,
note: 'add Images',
height: 470,
metaFields: [
{ id: 'name', name: 'Name', placeholder: 'file name' },
{ id: 'caption', name: 'Caption', placeholder: 'describe what the image is about' }
],
browserBackButtonClose: true
});
uppy.setMeta({
id: categoryId, entity: 'Entity\\Category'
});
uppy.use(XHRUpload, {
endpoint: attachment_files,
formData: true,
fieldName: 'files[]',
bundle: true,
metaFields: null,
getResponseData (responseText, response) {
return {
url: responseText
}
}
});
并且在服务器文件中不包含键标题
这就是我的档案
id: 112
entity: Entity\Category
files[]: (binary)
我尝试创建一些测试用例
files = {array} [5]
name = {array} [1]
0 = "Выделение_403.png"
type = {array} [1]
0 = "image/png"
tmp_name = {array} [1]
0 = "/tmp/phpmnkEMl"
error = {array} [1]
0 = {int} 0
size = {array} [1]
0 = {int} 145516
在服务器端,$\u文件['FILES']
没有包含test
键。您尝试过使用表单插件吗?
uppy.on('file-added', (file) =>{
console.log(file);
uppy.setFileMeta(file.id, {
test: 'hello'
});
});