使用 filepond 库时无法看到所选文件

Not able to see the selected files while using filepond library

我正在尝试使用 filepond 库上传文件。我正在使用 python flask 作为后端。

这是我试图用来获取文件的代码

uploaded_files = request.files.getlist("file")
print("Uplaoded Files are")
print(uploaded_files)

这总是返回一个空数组。

以下是我的html代码:

<form action="/", method='post',  enctype='multipart/form-data'>
<input type="file" class='filepond' name='file' multiple />
</form>

我还链接了 JS 和 CSS 的文件池库。

请帮我找出问题所在。

FilePond 不会更新原始输入字段,因为不幸的是,这是不可能的,因为浏览器不允许写入字段的 filesvalue 属性。更多信息:https://pqina.nl/blog/the-trouble-with-editing-and-uploading-files-in-the-browser/

因此,您要么必须异步上传文件(这就是 server 属性 的用途),要么必须将文件编码为 base64 字符串(您可以使用 file encode plugin 来做到这一点)并以经典形式发送它 post 然后在服务器上对其进行解码。