/* * jQuery File Upload Demo * https://github.com/blueimp/jQuery-File-Upload * * Copyright 2010, Sebastian Tschan * https://blueimp.net * * Licensed under the MIT license: * https://opensource.org/licenses/MIT */ /* global $ */ jQuery(function () { 'use strict'; // Initialize the jQuery File Upload widget: jQuery('#fileupload').fileupload({ // Uncomment the following to send cross-domain cookies: //xhrFields: {withCredentials: true}, url: 'server/php/', acceptFileTypes: /(\.|\/)(jpg|jpe?g|png|pdf|xls|xlsx)$/i }); // Enable iframe cross-domain access via redirect option: jQuery('#fileupload').fileupload( 'option', 'redirect', window.location.href.replace(/\/[^/]*$/, '/cors/result.html?%s') ); if (window.location.hostname === 'blueimp.github.io') { // Demo settings: jQuery('#fileupload').fileupload('option', { url: '//jquery-file-upload.appspot.com/', // Enable image resizing, except for Android and Opera, // which actually support image resizing, but fail to // send Blob objects via XHR requests: disableImageResize: /Android(?!.*Chrome)|Opera/.test( window.navigator.userAgent ), maxFileSize: 999000, acceptFileTypes: /(\.|\/)(jpg|jpe?g|png|pdf|xls|xlsx)$/i }); // Upload server status check for browsers with CORS support: if (jQuery.support.cors) { jQuery.ajax({ url: '//jquery-file-upload.appspot.com/', type: 'HEAD' }).fail(function () { jQuery('
') .text('Upload server currently unavailable - ' + new Date()) .appendTo('#fileupload'); }); } } else { // Load existing files: jQuery('#fileupload').addClass('fileupload-processing'); jQuery.ajax({ // Uncomment the following to send cross-domain cookies: //xhrFields: {withCredentials: true}, url: jQuery('#fileupload').fileupload('option', 'url'), dataType: 'json', acceptFileTypes: /(\.|\/)(jpg|jpe?g|png|pdf|xls|xlsx)$/i, context: jQuery('#fileupload')[0] }) .always(function () { jQuery(this).removeClass('fileupload-processing'); }) .done(function (result) { jQuery(this) .fileupload('option', 'done') // eslint-disable-next-line new-cap .call(this, jQuery.Event('done'), { result: result }); }); } });