Opened 8 years ago

Closed 8 years ago

Last modified 5 years ago

#7651 closed (fixed)

Bug when uploading lists of files

Reported by: julien Owned by: axiak
Component: HTTP handling Version: master
Severity: Keywords: upload, 2070-fix
Cc: axiak Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:



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 The code must enter the loop one time too much in the end somehow.


Attachments (1)

7651-fixes.diff (5.5 KB) - added by axiak 8 years ago.
Fixes with test for multiple files.

Download all attachments as: .zip

Change History (4)

comment:1 Changed 8 years ago by axiak

  • Cc axiak added
  • Component changed from Core framework to HTTP handling
  • Has patch set
  • Keywords 2070-fix added
  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to axiak
  • Patch needs improvement unset
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Accepted

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.

Changed 8 years ago by axiak

Fixes with test for multiple files.

comment:2 Changed 8 years ago by jacob

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [7858]) Fixed #7651: uploading multiple files with the same name now work. Also, in order to test the problem the test client now handles uploading multiple files at once. Patch from Mike Axiak.

comment:3 Changed 5 years ago by jacob

  • milestone 1.0 beta deleted

Milestone 1.0 beta deleted

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