gpt4 book ai didi

javascript - UIkit uploader : Getting the uploaded file

转载 作者:行者123 更新时间:2023-12-03 03:45:35 28 4
gpt4 key购买 nike

我需要获取上传的文件以将其推送到文件列表,但我无法做到这一点...我希望有人可以帮助我:

UIkit.upload('.test-upload', {
url: `/api/gridfs/${driver}`,

...

completeAll() {
setTimeout(function() {
bar.setAttribute('hidden', 'hidden');
}, 1000);

// Here: fileList.push(???);
}
});

我尝试过不同的方式,回调等,但都不起作用。我真的不知道怎么才能得到这个文件!!

提前谢谢您。

最佳答案

上传组件有url选项。这是脚本的地址,用于处理您的请求。上传插件仅处理前端。你如何准备后端,取决于你所使用的技术。在脚本内,您准备响应。它可以是带有一些参数的json。

在 php 中它可能看起来像:

//...upload procedures...set headers as text/json etc
$response = ['success' => true, 'filename' => $upload_data['filename']];
echo json_encode($response);
return true;

然后您可以检查上传插件使用的回调之一返回了什么。您将参数放在回调函数中,并尝试使用 console.log 查看您的 json 是否在其中。示例取自文档,并进行了一些修改:

 completeAll: function (arguments) { //added arguments, without it - arguments could be undefined in the line below
console.log('completeAll', arguments);

setTimeout(function () {
bar.setAttribute('hidden', 'hidden');
}, 1000);

alert('Upload Completed');
}

关于javascript - UIkit uploader : Getting the uploaded file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45405171/

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