So I am trying to upload a file without any external plugins, but I am running into some errors.
i followed this tutorial http://www.script-tutorials.com/pure-html5-file-upload/ and in the php part i replaced with :
class UploadImageView(LoginRequiredMixin, CurrentUserIdMixin, View):
@method_decorator(csrf_protect)
def dispatch(self, *args, **kwargs):
return super(UploadImageView, self).dispatch(*args, **kwargs)
def post(self, request, username):
path = 'myproject/media/pictures/guitar.jpg'
f = request.FILES['image_file']
destination = open(path, 'wb+')
for chunk in f.chunks():
destination.write(chunk)
destination.close()
return HttpResponse("image uploaded")
also changed this lines