Opened 3 years ago

Closed 3 years ago

Last modified 3 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 Changed 3 years ago by Tim Graham

Triage Stage: UnreviewedAccepted

comment:2 Changed 3 years ago by Berker Peksag

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

comment:3 Changed 3 years ago by Tim Graham

Patch needs improvement: set

comment:4 Changed 3 years ago by Berker Peksag

Patch needs improvement: unset

comment:5 Changed 3 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In 54febdb8:

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

comment:6 Changed 3 years ago by Tim Graham <timograham@…>

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 Changed 3 years ago by Tim Graham <timograham@…>

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