开发者

uploading file in django and python?

开发者 https://www.devze.com 2023-01-31 12:50 出处:网络
<input type=\"file\" name=\"doc-file\" multiple/> file_path = request.FILES.get(\'doc-file\') My return valu开发者_开发问答e of file_path is None
    <input type="file" name="doc-file" multiple/>

   file_path = request.FILES.get('doc-file')

My return valu开发者_开发问答e of file_path is None

But when I do file_path = request.POST.get('doc-file') it returns filename . What is the best way to upload a file in python and django?


It sounds like you might be forgetting to include enctype="multipart/form-data" in your form tag. See Django's docs on file uploads for details.

Edit: formatting

0

精彩评论

暂无评论...
验证码 换一张
取 消