Hi,I have problem with CakePHP request handling…
I wrote an API to post some data and files and use multipart/form-data when want to send data.
I wrote below code to convert json data to Array in beforeFilter of my controller:
$parser = function ($data) {
return json_decode($this->request->data,true);
};
$this->RequestHandler->addInputType("file", array($parser));
This is work and when I get $this->request->data in controller, JSON data successfully converted to Array,
But If I send request with file, this error happen:
Argument 1 passed to Hash::insert() must be of the type array, string given, called in /home/besepari/public_html/android/lib/Cake/Network/CakeRequest.php on line 401 and defined …
I know the problem but I couldn’t find a way to fix that.I think the error was generated because convert of $data from json to array is after of this event and data is string!
Can any one help me ?
I use cakephp 2
sorry for bad english.