angular-file-upload-html5-shim.js 1.2 KB

12345678910111213141516171819202122232425
  1. /**!
  2. * AngularJS file upload shim for angular XHR HTML5 browsers
  3. * @author Danial <danial.farid@gmail.com>
  4. * @version 1.1.10
  5. */
  6. if (window.XMLHttpRequest) {
  7. if (window.FormData) {
  8. // allow access to Angular XHR private field: https://github.com/angular/angular.js/issues/1934
  9. XMLHttpRequest = (function(origXHR) {
  10. return function() {
  11. var xhr = new origXHR();
  12. xhr.send = (function(orig) {
  13. return function() {
  14. if (arguments[0] instanceof FormData && arguments[0].__setXHR_) {
  15. var formData = arguments[0];
  16. formData.__setXHR_(xhr);
  17. }
  18. orig.apply(xhr, arguments);
  19. }
  20. })(xhr.send);
  21. return xhr;
  22. }
  23. })(XMLHttpRequest);
  24. }
  25. }