"use strict"; // jQuery FIle Upload Demo // ============================================================= $(function () { // Change this to the location of your server-side upload handler: var url = '//jquery-file-upload.appspot.com/'; // const url = (window.location.hostname === 'blueimp.github.io') ? '//jquery-file-upload.appspot.com/' : 'server/php/' // file upload avatar // ============================================================= $('#fileupload-avatar').fileupload({ url: url, dropZone: null, dataType: 'json', autoUpload: true, acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i, maxFileSize: 2000000 }).on('fileuploadprocessalways', function (e, data) { var index = data.index; var file = data.files[index]; $('#avatar-warning-container').removeClass('show').text(''); if (file.error) { $('#avatar-warning-container').addClass('show').text(file.error); } }).on('fileuploadprogressall', function (e, data) { var progress = parseInt(data.loaded / data.total * 100, 10); $('#progress-avatar').addClass('show').children().css('width', progress + '%'); }).on('fileuploaddone', function (e, data) { var file = data.result.files[0]; var $img = $(this).parent().children('img'); var $old = $img.prop('src'); if (file.url) { $img.prop('src', file.url); } else if (file.error) { $('#avatar-warning-container').addClass('show').text(file.error); } $('#progress-avatar').removeClass('show').children().css('width', 0); }); // File upload using button // ============================================================= var uploadButton = $('