multiple files upload using same input name in django

前端 未结 4 927
北海茫月
北海茫月 2020-11-30 02:45

i m having trouble in uploading multiple files with same input name:





        
4条回答
  •  孤街浪徒
    2020-11-30 03:18

    for f in request.FILES.getlist('file'):
        # do something with the file f...
    

    EDIT: I know this was an old answer, but I came across it just now and have edited the answer to actually be correct. It was previously suggesting that you could iterate directly over request.FILES['file']. To access all items in a MultiValueDict, you use .getlist('file'). Using just ['file'] will only return the last data value it finds for that key.

提交回复
热议问题