I have a sample Restler class:
class Author {
....
function post($request_data=NULL) {
var_dump($request_data);
var_dump($_FILES);
var_dump($_REQUEST);
return $this->dp->insert($this->_validate($request_data));
}
....
}
I’m trying to POST file and some data to Restler service by simple HTML form:
<FORM action="http://host/index.php/author" enctype="application/x-www-form-urlencoded" method="post">
Name: <INPUT type="text" name="name" value="dima"><BR>
Email: <INPUT type="text" name="email" value="dima@prot.lt"><BR>
File: <INPUT type="file" name="files"><BR>
<INPUT type="submit" value="Send"> <INPUT type="reset">
</FORM>
It is clear, that the $_FILES array will be empty, but $_REQUEST and $request_data will have three variables:
name = "dima", email = "dima@prot.lt" and file = "selected file name".
In the next test, I changed the form enctype value to multipart/form-data.
<FORM action="http://host/index.php/author" enctype="multipart/form-data" method="post">
Name: <INPUT type="text" name="name" value="dima"><BR>
Email: <INPUT type="text" name="email" value="dima@proto.lt"><BR>
File: <INPUT type="file" name="files"><BR>
<INPUT type="submit" value="Send"> <INPUT type="reset">
</FORM>
When I press submit form, in the $_REQUEST array, I will see the same three variables, the $_FILES array will be filled with uploaded file information, BUT the $request_data array will be empty!!
Can anybody help in this situation? Where have I made a mistake?
I have solved this issue, by writing Restler plugin, may be other will have the same problem: