Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- handleUpload = () ->
- $('#upload').on 'change', () ->
- files = $(this)[0].files;
- accepted_formats = [
- 'application/docx', 'application/doc', 'application/pdf', 'application/zip',
- 'application/rar', 'image/jpg', 'image/png', 'plain/text'
- ];
- max_size = 1e+7; # equivalent to 10mb
- _.each files, (file) ->
- unless _.contains(accepted_formats, file.type)
- resetUploadInput();
- Noty.new('Arquivo inválido. Apenas arquivos com extensão .zip, .rar, .pdf, .png, . jpg, .doc, .docx e .txt são aceitos.', 'alert');
- else if file.size > max_size
- resetUploadInput();
- Noty.new('O arquivo não pode ser maior que 10mb.', 'alert');
- resetUploadInput = () ->
- $("#upload").val('');
- $("label[for='upload'] span")[0].innerText = 'Incluir novo Anexo'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement