1

When I run

var data = new FormData();
data.append("somekey", "somevalue");
console.log("data = " + JSON.stringify(data)); // TEST

I get empty braces printed to the console. Why is this?

1 Answer 1

2

The FormData API doesn't include anything to expose the content of it back to the client.

It isn't empty. You just don't have a way to look at what is inside it.

The data you have appended will still appear when you send() it with XMLHttpRequest.

Sign up to request clarification or add additional context in comments.

2 Comments

How do I get that data from my controller action? If my controller is [HttpPost] public async Task<JsonResult> upload ( ) then how do I get somevalue from inside that controller?
@PeterThiel — I don't even know what programming language you are using there. How you read multipart form data in your framework of choice is a completely different problem to the one you are asking about here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.