I want to upload multiple files to the system (Local folder) without using Django forms or models. For a single file, everything works just fine and the file get saved to a local media folder under the project. But when I changed the function from {request.FILES['images'] } To {request.FILES.getlist('images')} to be able to upload multiple images I didn't get any error at all, but no images saved !!
I have a simple html form:
{ <form method="post" id="submitimg" enctype="multipart/form-data" name="images">
{% csrf_token %}
<label>Choose Images</label>
<input type="file" name="images[]" id="imgs" multiple >
<input type="submit" name="submit" value="UPLOAD"/>
</form> }
Python function:
{
def uploadmulti(request):
if request.method == 'POST' and request.FILES.getlist('images'):
files = request.FILES.getlist('images')
fs = FileSystemStorage()
file_url = fs.url(filename)
return render(request, 'home.html', {
'file_url':file_url
})
return render(request, 'upmulti.html')
}
I know I'm missing something!!!
Thank you