2 * jQuery File Upload Plugin JS Example 6.7
3 * https://github.com/blueimp/jQuery-File-Upload
5 * Copyright 2010, Sebastian Tschan
8 * Licensed under the MIT license:
9 * http://www.opensource.org/licenses/MIT
12 /*jslint nomen: true, unparam: true, regexp: true */
13 /*global $, window, document */
18 // Initialize the jQuery File Upload widget:
19 $('#fileupload').fileupload();
21 // Enable iframe cross-domain access via redirect option:
22 $('#fileupload').fileupload(
25 window.location.href.replace(
27 '/cors/result.html?%s'
31 if (window.location.hostname === 'blueimp.github.com') {
33 $('#fileupload').fileupload('option', {
34 url: '//jquery-file-upload.appspot.com/',
36 acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
40 fileTypes: /^image\/(gif|jpeg|png)$/,
41 maxFileSize: 20000000 // 20MB
53 // Upload server status check for browsers with CORS support:
56 url: '//jquery-file-upload.appspot.com/',
59 $('<span class="alert alert-error"/>')
60 .text('Upload server currently unavailable - ' +
62 .appendTo('#fileupload');
66 // Load existing files:
67 $('#fileupload').each(function () {
69 $.getJSON(this.action, function (result) {
70 if (result && result.length) {
71 $(that).fileupload('option', 'done')
72 .call(that, null, {result: result});