2 * jQuery File Upload Demo
3 * https://github.com/blueimp/jQuery-File-Upload
5 * Copyright 2010, Sebastian Tschan
8 * Licensed under the MIT license:
9 * https://opensource.org/licenses/MIT
17 // Initialize the jQuery File Upload widget:
18 $('#fileupload').fileupload({
19 // Uncomment the following to send cross-domain cookies:
20 //xhrFields: {withCredentials: true},
24 // Enable iframe cross-domain access via redirect option:
25 $('#fileupload').fileupload(
28 window.location.href.replace(/\/[^/]*$/, '/cors/result.html?%s')
31 if (window.location.hostname === 'blueimp.github.io') {
33 $('#fileupload').fileupload('option', {
34 url: '//jquery-file-upload.appspot.com/',
35 // Enable image resizing, except for Android and Opera,
36 // which actually support image resizing, but fail to
37 // send Blob objects via XHR requests:
38 disableImageResize: /Android(?!.*Chrome)|Opera/.test(
39 window.navigator.userAgent
42 acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i
44 // Upload server status check for browsers with CORS support:
47 url: '//jquery-file-upload.appspot.com/',
50 $('<div class="alert alert-danger"></div>')
51 .text('Upload server currently unavailable - ' + new Date())
52 .appendTo('#fileupload');
56 // Load existing files:
57 $('#fileupload').addClass('fileupload-processing');
59 // Uncomment the following to send cross-domain cookies:
60 //xhrFields: {withCredentials: true},
61 url: $('#fileupload').fileupload('option', 'url'),
63 context: $('#fileupload')[0]
66 $(this).removeClass('fileupload-processing');
68 .done(function (result) {
70 .fileupload('option', 'done')
71 // eslint-disable-next-line new-cap
72 .call(this, $.Event('done'), { result: result });