##// END OF EJS Templates
Fixed many edge cases in file uploads....
Jeffrey Bush -
Show More
@@ -96,6 +96,16 define([
96 that.add_file_data(event.target.result, item);
96 that.add_file_data(event.target.result, item);
97 that.add_upload_button(item);
97 that.add_upload_button(item);
98 };
98 };
99 reader.onerror = function (event) {
100 var item = $(event.target).data('item');
101 var name = item.data('name')
102 item.remove();
103 dialog.modal({
104 title : 'Failed to read file',
105 body : "Failed to read file '" + name + "'",
106 buttons : {'OK' : { 'class' : 'btn-primary' }}
107 });
108 };
99 }
109 }
100 // Replace the file input form wth a clone of itself. This is required to
110 // Replace the file input form wth a clone of itself. This is required to
101 // reset the form. Otherwise, if you upload a file, delete it and try to
111 // reset the form. Otherwise, if you upload a file, delete it and try to
@@ -364,6 +374,14 define([
364 var filename = item.find('.item_name > input').val();
374 var filename = item.find('.item_name > input').val();
365 var filedata = item.data('filedata');
375 var filedata = item.data('filedata');
366 var format = 'text';
376 var format = 'text';
377 if (filename.length === 0 || filename[0] === '.') {
378 dialog.modal({
379 title : 'Invalid file name',
380 body : "File names must be at least one character and not start with a dot",
381 buttons : {'OK' : { 'class' : 'btn-primary' }}
382 });
383 return false;
384 }
367 if (filedata instanceof ArrayBuffer) {
385 if (filedata instanceof ArrayBuffer) {
368 // base64-encode binary file data
386 // base64-encode binary file data
369 var bytes = '';
387 var bytes = '';
@@ -399,6 +417,7 define([
399 }
417 }
400 }}
418 }}
401 });
419 });
420 return false;
402 }
421 }
403 content_type = 'application/json';
422 content_type = 'application/json';
404 } else {
423 } else {
General Comments 0
You need to be logged in to leave comments. Login now