Как захватить данные php из angularJS?

Я смог отправить FormData из angularJS в php, но я не знаю, как сделать обратное. В настоящее время я пытаюсь получить переменную $ base64 в моем angularJS, но я совершенно не понимаю, как это сделать. Документация в официальном angularJS мне не очень помогает

https://docs.angularjs.org/api/ng/service/ $ http

JS

$scope.MakeGray_Button = function(){ if ($scope.imageUrl) { var MakeGray_Form = new FormData(); MakeGray_Form.append("FileName", $scope.imageUrl); $http({ method : "POST", url : "../opencv/MakeGray/MakeGray.php", data : MakeGray_Form, transformRequest: angular.identity, headers: {'Content-Type': undefined} }). success(function(){ // some magic code here that grabs the $base64 variable from php }) .error(function(){}); } else{ alert("Please upload an image"); } } 

PHP

 <?php $imgname = $_POST["FileName"]; $inputDir = "../../uploads/" . $imgname; $outputDir = "../../processed/" . $imgname; $MakeGray = "./makegray " . $inputDir . " " . $outputDir; $runExec = exec($MakeGray, $out); $type = pathinfo($outputDir, PATHINFO_EXTENSION); $data = file_get_contents($outputDir); $base64 = 'data:image/' . $type . ';base64,' . base64_encode($data); echo "$base64"; ?> 

Вы можете добавить параметр в успешный обратный вызов, чтобы получить ответ от сервера, если он доступен.

 var base64 = ''; $http({ method : "POST", url : "../opencv/MakeGray/MakeGray.php", data : MakeGray_Form, transformRequest: angular.identity, headers: {'Content-Type': undefined} }). success(function(response){ base64 = response; //response will contain whatever server echos to it's standard output }) .error(function(){});