JQuery Widget, parameters in $('#fileupload').fileupload(); to alert an error

JQuery Widget, parameters in $('#fileupload').fileupload(); to alert an error

I am trying to show the errors that can occur by uploading a file (file extension, size).

I have the following javascript:

 

  1.     <script type="text/javascript" charset="utf-8">
  2.                   $(function () {
  3.                       // Initialize the jQuery File Upload widget:
  4.                       $('#fileupload').fileupload();
  5.                       // 
  6.                       // Load existing files:
  7.                       $.getJSON($('#fileupload').prop('action'), function (files) {
  8.                         var fu = $('#fileupload').data('fileupload'), 
  9.                           template;
  10.                         fu._adjustMaxNumberOfFiles(-files.length);
  11.                         console.log(files);
  12.                         template = fu._renderDownload(files)
  13.                           .appendTo($('#fileupload .files'));
  14.                         // Force reflow:
  15.                         fu._reflow = fu._transition && template.length &&
  16.                           template[0].offsetWidth;
  17.                         template.addClass('in');
  18.                         $('#loading').remove();
  19.                       });
  20.                 
  21.                   });
  22.             </script>


I need to define the parameters in 
  1. `$('#fileupload').fileupload();`
 as told hier, so I thought of something like this but it does not work as I am not good at it at all =).
So, I need an alert message, if the file is not a jpg and if the size is too big.

  1.      $('#fileupload').fileupload({
  2.             dataType: "json"
  3.             add: (e,data)->
  4.               types = /(\.|\/)(jpg)$/i
  5.             
  6.               else
  7.                  alert("#{file.name} is not a jpg file")
  8.     
  9.         });

 

Many thanks in advanced