@alangreyjoy check the link I gave with it's documentation ;) it's on the top:
var formData = new FormData();
formData.append("username", "Groucho");
formData.append("accountnum", 123456); // number 123456 is immediately converted to a string "123456"
// HTML file input, chosen by user
formData.append("userfile", fileInputElement.files[0]);
// JavaScript file-like object
var content = '<a id="a"><b id="b">hey!</b></a>'; // the body of the new file...
var blob = new Blob([content], { type: "text/xml"});
formData.append("webmasterfile", blob);
var request = new XMLHttpRequest();
request.open("POST", "http://foo.com/submitform.php");
request.send(formData);
You can mix normal fields and files, just like in a normal form (just make a blob of the file first if it wasn't yet)
Going down the dot notation is going to be very hard to maintain because if the other side is programmed in PHP, you are still going to lose those dots in favor of underscores.
You could always create a separate Request class for you app, that simply takes the request input, and renames the keys back into dot notation.
Or perhaps, post a deeply nested javascript object (which turns into a PHP array after post) which you can read using laravel's dot notation, so posting:
formData.append("testinput", {
test: {
user: {
name: 'Lost',
email: [email protected]
}
}
});
can be read in php as:
$data = array_dot($request->get('testinput'));
$name = $data['test.user.name'];
$email = $data['test.user.email'];