Reputation: 11663
<input type="file" name="doc-file" multiple/>
file_path = request.FILES.get('doc-file')
My return value 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?
Upvotes: 1
Views: 128
Reputation: 5591
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
Upvotes: 3