#7651 closed (fixed)
Bug when uploading lists of files
| Reported by: | Julien Phalip | Owned by: | Michael Axiak |
|---|---|---|---|
| Component: | HTTP handling | Version: | dev |
| Severity: | Keywords: | upload, 2070-fix | |
| Cc: | Michael Axiak | Triage Stage: | Accepted |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Hi,
I'm using the jquery plugin MultiFile [1], which allows to dynamically create file fields in the form and then upload all the files when submitting the form.
It used to work totally fine before #2070 was merged. In my view I could do this:
file_dicts = []
for file_input_name in request.FILES:
file_dicts += request.FILES.getlist(file_input_name)
However, since #2070's merge, the last file selected with MultiFile is duplicated.
uploaded_files = []
for file_input_name in request.FILES:
uploaded_files += request.FILES.getlist(file_input_name)
uploaded_files returns:
list: [<TemporaryUploadedFile: test1.gif (image/gif)>, <TemporaryUploadedFile: test2.jpg (image/jpeg)>, <TemporaryUploadedFile: test2.jpg (image/jpeg)>]
The duplicate file to have an empty content. The problems happens both with TemporaryUploadedFile and InMemoryUploadedFile.
The MultiFile plugin is used by a lot of people on different platforms and with different web frameworks, and it used to work fine before #2070's merge, so to me this looks like a bug.
My first assumption is that the problem is in django.http.multipartparser.py. The code must enter the loop one time too much in the end somehow.
Attachments (1)
Change History (4)
comment:1 by , 17 years ago
| Cc: | added |
|---|---|
| Component: | Core framework → HTTP handling |
| Has patch: | set |
| Keywords: | 2070-fix added |
| Owner: | changed from to |
| Status: | new → assigned |
| Triage Stage: | Unreviewed → Accepted |
comment:2 by , 17 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
Thanks for the bug report.
I'm attaching a patch with tests to fix this bug. Leaving it accepted until someone other than me verifies this patch.