I am new to django, I am trying to upload more than one file from the browser and store them somewhere in computer storage but I am not storing them successfully with this c
views.py
from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def Form(request):
for x in request.FILES.getlist("files"):
def process(f):
with open('/Users/benq/djangogirls/upload/media/file_' + str(x), 'wb+') as destination:
for chunk in f.chunks():
destination.write(chunk)
process(x)
return render(request, "index/form.html", {})
urls.py
from django.conf.urls import url
from index import views
urlpatterns = [
url('form', views.Form),
]
worked for me.