[Answered ]-Django : Read multiple file from html form

2👍

My solution for getting multiple files from html and upload that files in django

index.html

<div id="fine-uploader-manual-trigger">
<input class="custom-file" type="file" name="imgname" id="productImgUpload" accept=".xlsx,.xls,image/*,.doc,audio/*,.docx,video/*,.ppt,.pptx,.txt,.pdf" multiple>
</div> 

views.py

filelist = request.FILES.getlist('imgname')
for i in range(len(filepath)):
      filename = filelist[i]

1👍

request.FILES is a MultiValueDict and doing get will return only the last value as you noted. If you want all of the values you should use images = request.FILES.getlist('image').

-1👍

i just try for getting multiple images from static folder to html page using for loop in Django.

{% for i in lst %}

   <td style="margin-left: 10px;">
   <img src="{% static '/images2/' %}{{i}}.png" style="width: 300px; height: 200px;">
{% endfor %}

Leave a comment