$(function () { 'use strict'; // Change this to the location of your server-side upload handler: var url = $('#file').data('action'); $('#file').fileupload({ url: url, autoUpload: false, maxFileSize: 700000000, // 700 MB type: 'PUT', contentType: 'video/mp4', multipart: false, progress: function (e, data) { var progress = parseInt(data.loaded / data.total * 100, 10); $('#progress .progress-bar').css( 'width', progress + '%' ); } }).on('fileuploadsend', function(e, data) { if(data.files.length > 1) { return false; } }).on('fileuploadprocessalways', function (e, data) { var index = data.index, file = data.files[index]; if(!file.error) { // add file to list var item = $('
').text(file.name); $('#files').append(item); // disable add files button $('.fileinput-button').remove(); // remove any previous error messages $('#error').fadeOut(function() { $(this).remove(); }) // bind upload button $('.fileupload-button') .prop('disabled', false) .on('click', function() { var $this = $(this), data = $(this).data(); $this.prop('disabled', true); $('#video').fadeIn(); data.submit().done(function() { $this.replaceWith('Upload erfolgreich. Bitte Formular ausfüllen und abschicken.'); // enable video form $('#video').find('input[type="submit"]').prop('disabled', false).end().prepend('') }); }).data(data); } else { $('#error').empty().text('Ungültiges Dateiformat.') } }).on('fileuploaddone', function (e, data) { $.each(data.result.files, function (index, file) { if (file.url) { var link = $('') .attr('target', '_blank') .prop('href', file.url); $(data.context.children()[index]) .wrap(link); } else if (file.error) { var error = $('').text(file.error); $(data.context.children()[index]) .append('