Google Chrome 11现在支持上传文件夹.目前此功能仅在Google文档中实现,我无法在我的代码中找到有关如何使用此功能的任何API文档.
从我所看到的,你点击谷歌文档中的上传文件夹链接,它显示"浏览文件夹"对话框(通过它的外观调用SHBrowseForFolder),你选择一个文件夹,然后该文件夹的内容是已上传到Google文档.
由于此功能需要将Google Chrome升级到最新版本,或者运行Java Applet的其他浏览器,我认为我可以在自己的网站中使用此功能?
我希望在我维护的内容管理系统中拥有此功能!
有没有办法用Flask接收多个上传的文件?我尝试过以下方法:
<form method="POST" enctype="multipart/form-data" action="/upload">
<input type="file" name="file[]" multiple="">
<input type="submit" value="add">
</form>
Run Code Online (Sandbox Code Playgroud)
然后打印出以下内容request.files['file']:
@app.route('/upload', methods=['POST'])
def upload():
if not _upload_dir:
raise ValueError('Uploads are disabled.')
uploaded_file = flask.request.files['file']
print uploaded_file
media.add_for_upload(uploaded_file, _upload_dir)
return flask.redirect(flask.url_for('_main'))
Run Code Online (Sandbox Code Playgroud)
如果我上传多个文件,它只打印集合中的第一个文件:
<FileStorage: u'test_file.mp3' ('audio/mp3')>
Run Code Online (Sandbox Code Playgroud)
有没有办法使用Flask的内置上传处理接收多个文件?谢谢你的帮助!