I use a private API using PHP and slim framework. When I get a route which gives me an image datas the response seems to be strange (like charset issue).
The server send the image with readfile() php function:
$src = "image.png";
$this->app->contentType("image/png");
$this->app->response()->status(REQ_OK);
header('Content-length: '.filesize(SITE_PATH.$src));
readfile(SITE_PATH.$src);
On client side I use AngularJS with $http.
$http({
method: 'GET',
url: "/myRoute",
headers: {
'responseType': "image/png"
}
)
.success(function(result){
//treatment
})
.error(function(){
});
On chrome, in the xhr preview i've got this: ![enter image description here][1]
See the screenshot here: https://i.stack.imgur.com/G5Cna.png
if I send data to ng-src of img it doesn't work. Because of the weird encode.
Have you any idea?
Thank you very much