4
I am doing a work 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 is 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 normally receive the file, I can move it to the location I need, but the parameters I am sending in the object date I am not being able to receive on my Web Service.
Could someone help me?? Vlw Galera.
I’ll test that way.
– Vinicius da Silva