Created
August 11, 2017 20:50
-
-
Save M-Yankov/367ac94f92954d53d02a82530dd81b10 to your computer and use it in GitHub Desktop.
Using FormData that works in internet explorer and file upload !
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var IEFormData = new FormData(); | |
| $divForm.find('input[name], textarea[name]') | |
| .each(function(i, el) { | |
| var val = $(el).val(); | |
| if (!val) { | |
| return; | |
| } | |
| if (el.type && el.type === 'file') { | |
| for (var i = 0; i < el.files.length; i++) { | |
| var file = el.files[i]; | |
| if (file.name !== '') { | |
| IEFormData.append(el.name, file); | |
| } | |
| } | |
| } else { | |
| IEFormData.append(el.name, $(el).val()); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment