Advertisement
Guest User

Untitled

a guest
Oct 20th, 2014
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. jQuery(document).ready(function(){
  2. $(function () {
  3. 'use strict';
  4.  
  5. // Initialize the jQuery File Upload widget:
  6. $('#fileupload').fileupload({
  7. // Uncomment the following to send cross-domain cookies:
  8. //xhrFields: {withCredentials: true},
  9. url: 'server/php/'
  10. });
  11.  
  12. // Enable iframe cross-domain access via redirect option:
  13. $('#fileupload').fileupload(
  14. 'option',
  15. 'redirect',
  16. window.location.href.replace(
  17. /\/[^\/]*$/,
  18. '/cors/result.html?%s'
  19. )
  20. );
  21.  
  22. if (window.location.hostname === 'blueimp.github.io') {
  23. // Demo settings:
  24. $('#fileupload').fileupload('option', {
  25. url: '//jquery-file-upload.appspot.com/',
  26. // Enable image resizing, except for Android and Opera,
  27. // which actually support image resizing, but fail to
  28. // send Blob objects via XHR requests:
  29. disableImageResize: /Android(?!.*Chrome)|Opera/
  30. .test(window.navigator.userAgent),
  31. maxFileSize: 5000000,
  32. acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i
  33. });
  34. // Upload server status check for browsers with CORS support:
  35. if ($.support.cors) {
  36. $.ajax({
  37. url: '//jquery-file-upload.appspot.com/',
  38. type: 'HEAD'
  39. }).fail(function () {
  40. $('<div class="alert alert-danger"/>')
  41. .text('Upload server currently unavailable - ' +
  42. new Date())
  43. .appendTo('#fileupload');
  44. });
  45. }
  46. } else {
  47. // Load existing files:
  48. $('#fileupload').addClass('fileupload-processing');
  49. $.ajax({
  50. // Uncomment the following to send cross-domain cookies:
  51. //xhrFields: {withCredentials: true},
  52. url: $('#fileupload').fileupload('option', 'url'),
  53. dataType: 'json',
  54. context: $('#fileupload')[0]
  55. }).always(function () {
  56. $(this).removeClass('fileupload-processing');
  57. }).done(function (result) {
  58. $(this).fileupload('option', 'done')
  59. .call(this, $.Event('done'), {result: result});
  60. });
  61. }
  62.  
  63. });
  64. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement