Commit a4e283e9 by kimth

File submission frontend checks for filesize

parent 3db07bca
...@@ -151,9 +151,16 @@ class @Problem ...@@ -151,9 +151,16 @@ class @Problem
fd = new FormData() fd = new FormData()
# Sanity check of file size
file_too_large = false
max_filesize = 10*1000*1000 # 10 MB
@inputs.each (index, element) -> @inputs.each (index, element) ->
if element.type is 'file' if element.type is 'file'
if element.files[0] instanceof File if element.files[0] instanceof File
if element.files[0].size > max_filesize
file_too_large = true
alert 'Submission aborted! Your file "' + element.files[0].name + '" is too large (max size: ' + max_filesize/(1000*1000) + ' MB)'
fd.append(element.id, element.files[0]) fd.append(element.id, element.files[0])
else else
fd.append(element.id, '') fd.append(element.id, '')
...@@ -173,7 +180,8 @@ class @Problem ...@@ -173,7 +180,8 @@ class @Problem
else else
alert(response.success) alert(response.success)
$.ajaxWithPrefix("#{@url}/problem_check", settings) if not file_too_large
$.ajaxWithPrefix("#{@url}/problem_check", settings)
check: => check: =>
Logger.log 'problem_check', @answers Logger.log 'problem_check', @answers
......
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