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:
- <script type="text/javascript" charset="utf-8">
- $(function () {
- // Initialize the jQuery File Upload widget:
- $('#fileupload').fileupload();
- //
- // Load existing files:
- $.getJSON($('#fileupload').prop('action'), function (files) {
- var fu = $('#fileupload').data('fileupload'),
- template;
- fu._adjustMaxNumberOfFiles(-files.length);
- console.log(files);
- template = fu._renderDownload(files)
- .appendTo($('#fileupload .files'));
- // Force reflow:
- fu._reflow = fu._transition && template.length &&
- template[0].offsetWidth;
- template.addClass('in');
- $('#loading').remove();
- });
-
- });
- </script>
I need to define the parameters in
- `$('#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.
- $('#fileupload').fileupload({
- dataType: "json"
- add: (e,data)->
- types = /(\.|\/)(jpg)$/i
-
- else
- alert("#{file.name} is not a jpg file")
-
- });
Many thanks in advanced