123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- /*
- * 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 $ */
- $(function () {
- 'use strict';
- // Initialize the jQuery File Upload widget:
- $('#fileupload').fileupload({
- // Uncomment the following to send cross-domain cookies:
- //xhrFields: {withCredentials: true},
- url: 'lib/jQuery-File-Upload-master/server/php/'
- });
- // Enable iframe cross-domain access via redirect option:
- $('#fileupload').fileupload(
- 'option',
- 'redirect',
- window.location.href.replace(/\/[^/]*$/, 'lib/jQuery-File-Upload-master//cors/result.html?%s')
- );
- if (window.location.hostname === 'blueimp.github.io') {
- // Demo settings:
- $('#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: /(\.|\/)(gif|jpe?g|png)$/i
- });
- // Upload server status check for browsers with CORS support:
- if ($.support.cors) {
- $.ajax({
- url: '//jquery-file-upload.appspot.com/',
- type: 'HEAD'
- }).fail(function () {
- $('<div class="alert alert-danger"/>')
- .text('Upload server currently unavailable - ' + new Date())
- .appendTo('#fileupload');
- });
- }
- } else {
- $('#fileupload').fileupload('option', {
- // 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
- ),
- imageMaxWidth: 100,
- imageMaxHeight: 100,
- maxFileSize: 9999999,
- acceptFileTypes: /(\.|\/)(txt|gif|jpe?g|png)$/i
- });
- // Load existing files:
- $('#fileupload').addClass('fileupload-processing');
- $.ajax({
- // Uncomment the following to send cross-domain cookies:
- //xhrFields: {withCredentials: true},
- url: $('#fileupload').fileupload('option', 'url'),
- dataType: 'json',
- context: $('#fileupload')[0]
- })
- .always(function () {
- $(this).removeClass('fileupload-processing');
- })
- .done(function (result) {
- $(this)
- .fileupload('option', 'done')
- // eslint-disable-next-line new-cap
- .call(this, $.Event('done'), { result: result });
- });
- }
- });
|