<input type="file" name="doc-file" multiple/>
file_path = request.FILES.get('doc-file')
我的file_path的返回值为None
但是当我执行 file_path = request.POST.get('doc-file')
时,它会返回 filename
。在 python 和 django 中上传文件的最佳方式是什么?
最佳答案
听起来您可能忘记在表单标记中包含 enctype="multipart/form-data"
。请参阅Django's docs on file uploads了解详情。
编辑:格式
关于python - 在django和python中上传文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4483020/