user426795
user426795

Reputation: 11663

uploading file in django and python?

    <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

Answers (1)

Gabriel Grant
Gabriel Grant

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

Related Questions