I have a button where I select a file, I would like to upload this file to my server ( Java + Vraptor
). I can already get the file and also save the file name in the database along with the data of the collaborator. Now we just need to send this file to the server. I'm using this template.
I upload it this way:
$scope.uploadFiles = function(file) {
$scope.f = file;
}
var salvarImagem = function(file) {
if (file && !file.$error) {
file.upload = Upload.upload({
//Não sei o que colocar aqui!
url: 'https://angular-file-upload-cors-srv.appspot.com/upload',
data: {
file: file
}
});
file.upload.then(function(response) {
$timeout(function() {
file.result = response.data;
console.log("REsposta: " + response.data);
});
}, function(response) {
if (response.status > 0)
$scope.errorMsg = response.status + ': ' + response.data;
});
file.upload.progress(function(evt) {
file.progress = Math.min(100, parseInt(100.0 *
evt.loaded / evt.total));
});
}
}
Then I call the function salvarImagem
within my function that saves the Contributor:
$scope.adicionarColaborador = function(colaborador) {
if (!editar) {
colaborador.arquivo = $scope.f.name;
console.log('colaborador: ' + colaborador.arquivo)
colaboradorAPI.saveColaborador(colaborador).success(function(data) {
salvarImagem($scope.f);
.../Código omitido
What is the next step now? How to receive this image on my server and save it to a directory, or how to save that image to a direct directory?