Commit 76c8e33d by Christine Lytwynec

Fix file upload in IE

parent fdf540d2
import functools import functools
import logging import logging
import json
import random import random
import time import time
import urlparse import urlparse
...@@ -7,7 +8,7 @@ import urlparse ...@@ -7,7 +8,7 @@ import urlparse
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.core import exceptions from django.core import exceptions
from django.http import Http404, HttpResponseBadRequest from django.http import Http404, HttpResponseBadRequest, HttpResponse
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.views.decorators import csrf from django.views.decorators import csrf
from django.views.decorators.http import require_GET, require_POST from django.views.decorators.http import require_GET, require_POST
...@@ -750,13 +751,16 @@ def upload(request, course_id): # ajax upload file to a question or answer ...@@ -750,13 +751,16 @@ def upload(request, course_id): # ajax upload file to a question or answer
result = '' result = ''
file_url = '' file_url = ''
return JsonResponse({ # Using content-type of text/plain here instead of JSON because
# IE doesn't know how to handle the JSON response and prompts the
# user to save the JSON as a file instead of passing it to the callback.
return HttpResponse(json.dumps({
'result': { 'result': {
'msg': result, 'msg': result,
'error': error, 'error': error,
'file_url': file_url, 'file_url': file_url,
} }
}) }), content_type="text/plain")
@require_GET @require_GET
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment