Commit e685ff71 by chrisndodge

Merge pull request #129 from edx/fix/cdodge/cancel-asset-upload-crash

[STUD-256] Seems like on chrome when cancel is hit in the file chooser, the 'change...
parents d4a5af85 be6fbf91
...@@ -103,6 +103,9 @@ def upload_asset(request, org, course, coursename): ...@@ -103,6 +103,9 @@ def upload_asset(request, org, course, coursename):
logging.error('Could not find course' + location) logging.error('Could not find course' + location)
return HttpResponseBadRequest() return HttpResponseBadRequest()
if 'file' not in request.FILES:
return HttpResponseBadRequest()
# compute a 'filename' which is similar to the location formatting, we're using the 'filename' # compute a 'filename' which is similar to the location formatting, we're using the 'filename'
# nomenclature since we're using a FileSystem paradigm here. We're just imposing # nomenclature since we're using a FileSystem paradigm here. We're just imposing
# the Location string formatting expectations to keep things a bit more consistent # the Location string formatting expectations to keep things a bit more consistent
......
...@@ -411,8 +411,12 @@ function showFileSelectionMenu(e) { ...@@ -411,8 +411,12 @@ function showFileSelectionMenu(e) {
} }
function startUpload(e) { function startUpload(e) {
var files = $('.file-input').get(0).files;
if (files.length === 0)
return;
$('.upload-modal h1').html(gettext('Uploading…')); $('.upload-modal h1').html(gettext('Uploading…'));
$('.upload-modal .file-name').html($('.file-input').val().replace('C:\\fakepath\\', '')); $('.upload-modal .file-name').html(files[0].name);
$('.upload-modal .file-chooser').ajaxSubmit({ $('.upload-modal .file-chooser').ajaxSubmit({
beforeSend: resetUploadBar, beforeSend: resetUploadBar,
uploadProgress: showUploadFeedback, uploadProgress: showUploadFeedback,
......
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