Just recently, support for multipart/form-data upload was added to Restler v3 (source) but I can't get it to work. In my index.php file, I've added:
$r->setSupportedFormats('JsonFormat', 'UploadFormat');
When I post a .txt file, I get the following error (which is expected, since the default 'allowed' format is 'image/jpeg', 'image/png':
"error": {
"code": 403,
"message": "Forbidden: File type (text/plain) is not supported."
}
But when I post a .jpg file, I get the following error instead:
"error": {
"code": 404,
"message": "Not Found"
}
What am I missing? Here is my function:
function upload() {
if (empty($request_data)) {
throw new RestException(412, "requestData is null");
}
return array('upload_status'=>'image uploaded successfully');
}