Opened 9 years ago

Closed 8 years ago

Last modified 8 years ago

#26604 closed New feature (fixed)

Add example of simple multiple file upload in documentation

Reported by: zxcq544 Owned by: Berker Peksag
Component: Documentation Version: 1.9
Severity: Normal Keywords: doumentation, multiple file upload, upload many files
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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)

comment:1 by Tim Graham, 9 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Berker Peksag, 9 years ago

Has patch: set
Owner: changed from nobody to Berker Peksag
Status: newassigned

comment:3 by Tim Graham, 8 years ago

Patch needs improvement: set

comment:4 by Berker Peksag, 8 years ago

Patch needs improvement: unset

comment:5 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: assignedclosed

In 54febdb8:

Fixed #26604 -- Added a multiple file upload example to topics/http/file-uploads.txt.

comment:6 by Tim Graham <timograham@…>, 8 years ago

In 7407440:

[1.9.x] Fixed #26604 -- Added a multiple file upload example to topics/http/file-uploads.txt.

Backport of 54febdb8be7c9793caae9c781f4d6b7cbbdcd900 from master

comment:7 by Tim Graham <timograham@…>, 8 years ago

In 27983d82:

[1.10.x] Fixed #26604 -- Added a multiple file upload example to topics/http/file-uploads.txt.

Backport of 54febdb8be7c9793caae9c781f4d6b7cbbdcd900 from master

Note: See TracTickets for help on using tickets.
Back to Top