I'm doing a job with Angular (version 1.5.8) and using Silex as Web Service. To send the file to the Web Service I am using Angular-File-Upload (version 1.5.1), and my Angular service is like this:
self.salvarAnexo = function (id, descricao, anexo) {
var deferred = $q.defer();
var url = "http://127.0.0.1:8080/salvar-anexo";
$upload.upload({
url: url,
data: {
id: id,
descricao: descricao,
},
file: anexo
}).then(function (response) {
deferred.resolve(response);
}, function (error) {
deferred.reject(error);
});
return deferred.promise;
};
And the Web Service looks like this:
$this->controllers->post('/salvar-anexo', function (Application $app, Request $request) {
$file = $request->files->get('file');
if($file){
$file->move(__DIR__ . '/../../../temp', $file->getClientOriginalName());
}
//$params = $request->request->all();
var_dump($request->files);
exit;
I usually get the file, I can move it to the location I need, but the parameters I'm sending in the data object I can not get in my Web Service.
Could anyone help me ??? Vlw Galera.