Javascript 为什么我的文件上传(到Flask服务器)没有出现在request.files中,而是出现在request.stream中?
我有一个表单(恰好在iframe中)如下所示:Javascript 为什么我的文件上传(到Flask服务器)没有出现在request.files中,而是出现在request.stream中?,javascript,python,flask,Javascript,Python,Flask,我有一个表单(恰好在iframe中)如下所示: <form id='picture-file-input-button' action='/post-picture' method='post' enctype='multipart/form-data' encoding='multipart/form-data'> <button type='button' class='choose-picture-button'>Choose picture</but
<form id='picture-file-input-button' action='/post-picture' method='post' enctype='multipart/form-data' encoding='multipart/form-data'>
<button type='button' class='choose-picture-button'>Choose picture</button>
<input class='picture-file-input' type='file' />
</form>
调试所有输出空的ImmutableMultiDict,但request.stream除外,它输出:
<werkzeug.wsgi.LimitedStream object at 0x9a7d30c>
我希望看到文件显示在request.files中。为什么它没有显示在request.files中?除非文件输入元素设置了name属性,否则不会填充request.files。name属性可以设置为任何值。因此,上述代码的修复方法是更改:
<input class='picture-file-input' type='file' />
到
<input class='picture-file-input' type='file' />
<input class='picture-file-input' type='file' name='picture' />