Created
July 13, 2016 18:10
-
-
Save smddzcy/6f8da82e67603f5132dcd0b57be8808f to your computer and use it in GitHub Desktop.
This file contains 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
objToFormData = (obj, formData, prefix) -> | |
formData ?= new FormData | |
formKey = null | |
angular.forEach obj, (val, key) -> | |
if prefix? | |
formKey = "#{prefix}[#{key}]" | |
else | |
formKey = key | |
if typeof val is 'object' and val.constructor isnt File | |
objToFormData(val, formData, formKey) | |
else | |
formData.append formKey, val | |
formData |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment