Send image via POST to angularjs

-1

HELP. I'm trying to send an image to a web service via POST. in postman I tested it and it worked

InmycontrollerIdidso

$scope.upload=function(files){varfd=newFormData();fd.append('imagem',files[0]);midanaAPI.cadastrarImagem(fd).success(function(data){if(data.Status){$scope.foto=data.UrlImage;}else{$scope.mensagemErro="Não foi possível carregar a Imagem, tente novamente.";
                    }
                });
    }

this midanaAPI.score image (fd) is calling my service, follow the code

var _cadastrarImagem = function (imagem) {
    var data = 'Foto='+imagem;
    var config = {
        headers: {
            'Content-Type': undefined,
            'Device': "midayas.Device",
            'Token': "midayas.Token"
        }
    };
    return $http.post(configValor.baseUrl + "Upload/File", data, config);
};

Only the Web Service does not find any files in the request.

    
asked by anonymous 07.03.2017 / 22:21

1 answer

0

solved ... it was just bullshit. instead of image the server was waiting Photo then the line  fd.append ('image', files [0]); stayed like this  fd.append ('Photo', files [0]);

    
08.03.2017 / 02:56