Django Upload Files Proving More Difficult Than Necessary
I am trying to allow for files to be uploaded by users in on my django site. I started with the example command from the django documentation, input into views.py, independently of
Solution 1:
Your indentation is wrong! The correct indentation is give below, there has to be 4 space indent
from django.shortcuts import render
from django.http import HttpResponse
def Upload(request):
for count, x in enumerate(request.FILES.getlist("files")):
def process(f):
with open('/Users/Michel/django_1.8/projects/upload/media/file_' + str(count), 'wb+') as destination:
for chunk in f.chunks():
destination.write(chunk)
process(x)
return HttpResponse("File(s) uploaded!")
Post a Comment for "Django Upload Files Proving More Difficult Than Necessary"