|
1 | 1 | /*
|
2 |
| - * jQuery File Upload Plugin 5.11.3 |
| 2 | + * jQuery File Upload Plugin 5.12 |
3 | 3 | * https://github.com/blueimp/jQuery-File-Upload
|
4 | 4 | *
|
5 | 5 | * Copyright 2010, Sebastian Tschan
|
|
776 | 776 | }
|
777 | 777 | },
|
778 | 778 |
|
| 779 | + _getFileInputFiles: function (fileInput) { |
| 780 | + fileInput = $(fileInput); |
| 781 | + var files = $.each($.makeArray(fileInput.prop('files')), this._normalizeFile), |
| 782 | + value; |
| 783 | + if (!files.length) { |
| 784 | + value = fileInput.prop('value'); |
| 785 | + if (!value) { |
| 786 | + return []; |
| 787 | + } |
| 788 | + // If the files property is not available, the browser does not |
| 789 | + // support the File API and we add a pseudo File object with |
| 790 | + // the input value as name with path information removed: |
| 791 | + files = [{name: value.replace(/^.*\\/, '')}]; |
| 792 | + } |
| 793 | + return files; |
| 794 | + }, |
| 795 | + |
779 | 796 | _onChange: function (e) {
|
780 | 797 | var that = e.data.fileupload,
|
781 | 798 | data = {
|
782 |
| - files: $.each($.makeArray(e.target.files), that._normalizeFile), |
783 | 799 | fileInput: $(e.target),
|
784 | 800 | form: $(e.target.form)
|
785 | 801 | };
|
786 |
| - if (!data.files.length) { |
787 |
| - // If the files property is not available, the browser does not |
788 |
| - // support the File API and we add a pseudo File object with |
789 |
| - // the input value as name with path information removed: |
790 |
| - data.files = [{name: e.target.value.replace(/^.*\\/, '')}]; |
791 |
| - } |
| 802 | + data.files = that._getFileInputFiles(data.fileInput); |
792 | 803 | if (that.options.replaceFileInput) {
|
793 | 804 | that._replaceFileInput(data.fileInput);
|
794 | 805 | }
|
|
925 | 936 | if (!data || this.options.disabled) {
|
926 | 937 | return;
|
927 | 938 | }
|
928 |
| - data.files = $.each($.makeArray(data.files), this._normalizeFile); |
| 939 | + if (data.fileInput && !data.files) { |
| 940 | + data.files = this._getFileInputFiles(data.fileInput); |
| 941 | + } else { |
| 942 | + data.files = $.each($.makeArray(data.files), this._normalizeFile); |
| 943 | + } |
929 | 944 | this._onAdd(null, data);
|
930 | 945 | },
|
931 | 946 |
|
|
936 | 951 | // The method returns a Promise object for the file upload call.
|
937 | 952 | send: function (data) {
|
938 | 953 | if (data && !this.options.disabled) {
|
939 |
| - data.files = $.each($.makeArray(data.files), this._normalizeFile); |
| 954 | + if (data.fileInput && !data.files) { |
| 955 | + data.files = this._getFileInputFiles(data.fileInput); |
| 956 | + } else { |
| 957 | + data.files = $.each($.makeArray(data.files), this._normalizeFile); |
| 958 | + } |
940 | 959 | if (data.files.length) {
|
941 | 960 | return this._onSend(null, data);
|
942 | 961 | }
|
|
0 commit comments