Я устал от этого и сделал это с сохранением изображения.
Controller.js:
$scope.guestPrint = function() {
$http({
url: request_server + 'guestprint.php',
method: 'POST',
data: $scope.admin, //dont mind this
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}).success(function(response, status, headers, config) {
$http({
url: request_server + 'guestdw.php',
method: 'POST',
data: { user: $rootScope.user }, //dont mind this
responseType: 'arraybuffer',
headers: {
'Content-Type': 'application/x-www-form-urlencoded' //!important
}
}).success(function(response, status, headers, config) {
var blob = new Blob([response], {
type: "image/jpeg"
});
var objectUrl = URL.createObjectURL(blob);
window.open(objectUrl);
});
});
}
guestdw.php:
$yourfile = "./path/to/file.jpeg";
$file_name = basename($yourfile);
header('Content-Description: File Transfer');
header('Content-Type: image/jpeg');
header('Content-Disposition: attachment; filename="'.($file_name).'"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($yourfile));
readfile($yourfile);