0

i need to pass the file name from Django template to views.py . It works fine if i am passing one file name ,but when it comes to multiple file i am able to select multiple files but in views.py only the first file is showing . BTW i am new to Django . Please correct me if i am going worng.

Html code :

   <form method="post" action="add" enctype='multipart/form-data' >
           {% csrf_token%}
          <div class="form-group files">
            <label>Upload Your File </label>
            <input type="file" class="form-control"  name="num1[]" 
            multiple/>
              <button type="submit" class="form-control" >Submit</button>
          </div>
        </form>

Python code :

def add(request):

val1 = request.POST['num1']
print(val1)

Expect result : [File1 , File2]

list or dictionary is fine

Actual result : file1
#needed both file names

3
  • Are you uploading multiple files by using shift+select? Commented Nov 7, 2019 at 8:21
  • @JayVasant yes i am selecting using shift+select Commented Nov 7, 2019 at 10:23
  • Can you post your what's coming in your request, or you can refer here: stackoverflow.com/questions/39525188/… Commented Nov 7, 2019 at 11:20

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.