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>
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26604>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_docs: => 0
* needs_better_patch: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/26604#comment:1>
* owner: nobody => berkerpeksag
* status: new => assigned
* has_patch: 0 => 1
Comment:
https://github.com/django/django/pull/6603
--
Ticket URL: <https://code.djangoproject.com/ticket/26604#comment:2>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/26604#comment:3>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/26604#comment:4>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"54febdb8be7c9793caae9c781f4d6b7cbbdcd900" 54febdb8]:
{{{
#!CommitTicketReference repository=""
revision="54febdb8be7c9793caae9c781f4d6b7cbbdcd900"
Fixed #26604 -- Added a multiple file upload example to topics/http/file-
uploads.txt.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26604#comment:5>
Comment (by Tim Graham <timograham@…>):
In [changeset:"27983d82c2415f02d962649b6623a20493b1790b" 27983d82]:
{{{
#!CommitTicketReference repository=""
revision="27983d82c2415f02d962649b6623a20493b1790b"
[1.10.x] Fixed #26604 -- Added a multiple file upload example to
topics/http/file-uploads.txt.
Backport of 54febdb8be7c9793caae9c781f4d6b7cbbdcd900 from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26604#comment:7>
Comment (by Tim Graham <timograham@…>):
In [changeset:"7407440885f1777abb88f18832ecedc3460f2506" 7407440]:
{{{
#!CommitTicketReference repository=""
revision="7407440885f1777abb88f18832ecedc3460f2506"
[1.9.x] Fixed #26604 -- Added a multiple file upload example to
topics/http/file-uploads.txt.
Backport of 54febdb8be7c9793caae9c781f4d6b7cbbdcd900 from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26604#comment:6>