From what I have seen in the post that I left there is a bug in PHP that makes the request null with this type of content type, does anyone have a solution to pass files to a service rest with the method put? .I have solved it using post, but that kills the specification of a REST API that says that the editing must be through the PUT method.
the call is made with angular like this:
...
var noticiasForm = new FormData(document.getElementById("noticiasForm"));
var config = {
headers : {
'Content-Type': undefined
},
transformRequest: angular.identity
};
global = $http.put(path+'noticias/'+noticia.id, noticiasForm, config);
return global;
and in the controller I do this:
/**
* Edita una noticia
* Put action
* @var Request $request
* @var Noticias $noticia
* @return View|array
*
* @View()
* @Put("/noticias/{id}")
*/
public function editNoticiaAction(Request $request, $id)
{
$errores = array();
$d1 = file_get_contents("php://input");
$foto = $request->files->get('foto_noti');
$titulo = $request->request->get('titulo_noti');
$texto = $request->request->get('texto_noti');
$id_usu = $request->request->get('id_usuario');
}
None of the data that I am trying to obtain in the request arrives filled, Everything works fine with the POST method.
Finally, a reflection, we are thinking about moving to Java for these things, the REST and PHP services, together with symfony do not seem to be very much in their own, as they say in that thread, the bug is from 2011 and still continues alive. This seems a serious disaster, so we consider the possibility of changing the entire REST API to Java. Any recommendation? Do you think the same as me?