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()
filename = fs.save(files.name, files
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
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/eed60651-3096-4538-a7f5-0fca018a7dbc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment