alert"Sorry, your browser does not support file uploads. Your submit request could not be fulfilled. If you can, please use Chrome or Safari which have been verified to support file uploads."
alert"Submission aborted! Sorry, your browser does not support file uploads. If you can, please use Chrome or Safari which have been verified to support file uploads."
return
fd=newFormData()
# Sanity check of file size
abort_submission=false
# Sanity checks on submission
max_filesize=4*1000*1000# 4 MB
file_too_large=false
file_not_selected=false
@inputs.each(index,element)->
ifelement.typeis'file'
forfileinelement.files
iffile.size>max_filesize
abort_submission=true
file_too_large=true
alert'Submission aborted! Your file "'+file.name'" is too large (max size: '+max_filesize/(1000*1000)+' MB)'
fd.append(element.id,file)
ifelement.files.length==0
abort_submission=true
alert'Submission aborted! You did not select any files to submit'
fd.append(element.id,'')
file_not_selected=true
fd.append(element.id,'')# In case we want to allow submissions with no file
else
fd.append(element.id,element.value)
iffile_not_selected
alert'Submission aborted! You did not select any files to submit'