Saturday, May 11, 2024
 Popular · Latest · Hot · Upcoming
114
rated 0 times [  117] [ 3]  / answers: 1 / hits: 7809  / 8 Years ago, wed, december 7, 2016, 12:00:00

I have an ajax function that posts an image, which works perfectly in Chrome and Firefox. Safari and iOS Safari both balk at it, though.



I'm creating and appending the value like this:



var ajaxImage = new FormData();
ajaxImage.append('file-0', $('.some-file-input')[0].files[0]);


I then call this image later, using ajaxImage.entries() to init the iterator for the FormData object, so that I can perform a validation on it. However, in Safari ajaxImage.entries() throws an entries is not a function TypeError.



I guess I could just do the validation before getting to this point as a workaround, but now it's bugging me so I wanted to see if anyone could shed some light on this.



Thanks!


More From » ios

 Answers
3

Unfortunately, Safari doesn't support this part of the specification: https://developer.mozilla.org/en-US/docs/Web/API/FormData#Browser_compatibility, specifically the entries method.



I haven't tried it myself, but perhaps a polyfill like this one: https://github.com/francois2metz/html5-formdata might work?



But yes, you might be right -- doing validation before that point might be worth it.


[#24344] Tuesday, December 6, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ednakarolinal

Total Points: 187
Total Questions: 106
Total Answers: 118

Location: Saint Helena
Member since Mon, Jan 16, 2023
1 Year ago
;