1

I have the following variable called request.FILES which contain the following:

<MultiValueDict: {
    u'uploadedFile': [
        <InMemoryUploadedFile: angularjs1.png (image/png)>,
        <InMemoryUploadedFile: angularjs2.png (image/png)>,
        <InMemoryUploadedFile: angularjs3.png (image/png)>]}>

If I call or print request.FILES['uploadedFile'] I get only angularjs3.png and I need a list like angularjs1.png, angularjs2.png, angularjs3.png or something similar. I think I need a for loop but I didn't succeed how to make it properly.

unutbu
  • 842,883
  • 184
  • 1,785
  • 1,677
MariusNV
  • 391
  • 1
  • 3
  • 7

1 Answers1

4

You have a special type of dictionary, a MultiValueDict. Using the .get() method or [...] indexing will only ever get you the first value.

You need to use the .getlist() method instead:

request.FILES.getlist('uploadedFile')
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343