I'm trying to upload a file, and some data to my server, using Angular JS to make a POST request via AJAX, while my back end is Laravel 4 (not that it matters much here).
Now I successfully pass this data to my controller. I'm able to do the following:
$data = Input::all();
return $data;
I console.log
the data out when the response is successful, and it produces:
Object {
imageData: "{"title":"Some Title","owner":"Owner Name","source":"Source Name"}",
file: Object
}
Okay so this is what I want, but more specifcically I want the stuff inside of imageData
.
$data = Input::all();
$imageData = $data['imageData'];
return $imageData;
Okay so console.log
that back:
Object {title: "Some Title", owner: "Owner Name", source: "Source Name"}
Great - but now lets grab the individual elements following that trend:
$data = Input::all();
$imageData = $data['imageData'];
$title = $imageData['title'];
return $title;
Nope: 500 (Internal Server Error)
. Same happens why I try to access it as an object ($title = $imageData->title
.
So how am I supposed to grab the stuff inside of there?