Skip to content

Instantly share code, notes, and snippets.

View macwac's full-sized avatar
🍕

Maciej Gorczyn macwac

🍕
  • Transfer Multisort Elektronik
  • Gdańsk, Poland
View GitHub Profile
@ghinda
ghinda / object-to-form-data.js
Last active May 13, 2025 05:55
JavaScript Object to FormData, with support for nested objects, arrays and File objects. Includes Angular.js usage.
// takes a {} object and returns a FormData object
var objectToFormData = function(obj, form, namespace) {
var fd = form || new FormData();
var formKey;
for(var property in obj) {
if(obj.hasOwnProperty(property)) {
if(namespace) {