[Fixed]-Django multiple files upload only returns the last file

1👍

If you’re try to upload multiple files with a single InputFile it won’t work. You will only recieve the last selected file. You need an InputFile for each one.

Docs

<form enctype="multipart/form-data" role="form" method = "post">
    {% csrf_token %}
    {% load bootstrap %}
    {{form|bootstrap}}
    <input type="file" id="upload1" name="myfiles[]">
    <input type="file" id="upload2" name="myfiles[]">
    <input type="file" id="upload3" name="myfiles[]">
    <div id="upload_prev"></div>
    <button type="submit">{% trans "upload_lesson_plan" %}</button>
</form>

You may want to try django-multiupload Which says in its description allow multiple file upload with a single input file.

Similar Question

Leave a comment