Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67441

passing Multiple File name from Django templates to views in python

$
0
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


Viewing all articles
Browse latest Browse all 67441

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>