I'm trying to upload file using uploadhandler in Django. But it's returning the error:
You cannot alter upload handlers after the upload has been processed
Code:
def upload_form(request):
if request.method == 'POST':
outPath = '/opt/workspace/jup2/juppro/uploads/23232'
if not os.path.exists(outPath):
os.makedirs(outPath)
request.upload_handlers.insert(0, ProgressUploadHandler(request, outPath)) # place our custom upload in first position
upload_file = request.FILES.get('file', None) # start the upload
return HttpResponse("uploaded ok")
What's wrong with that code?