Add example of simple multiple file upload in documentation
At https://docs.djangoproject.com/en/1.9/topics/http/file-uploads/ we could add simple example of multiple file upload:
In views.py
def handle_uploaded_files(files):
for i in files:
with open('uploads/' + i.name, 'wb+') as destination:
for chunk in i.chunks():
destination.write(chunk)
def upload_file(request):
if request.method == 'POST':
handle_uploaded_files(request.FILES.getlist('files[]'))
return render(request, 'upload.html')
In upload.html
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
<input type="file" name="files[]" multiple>
<input type="submit" value="Send">
</form>
Change History
(7)
Triage Stage: |
Unreviewed → Accepted
|
Has patch: |
set
|
Owner: |
changed from nobody to Berker Peksag
|
Status: |
new → assigned
|
Patch needs improvement: |
set
|
Patch needs improvement: |
unset
|
Resolution: |
→ fixed
|
Status: |
assigned → closed
|
https://github.com/django/django/pull/6603