Use PHP to save or display image returned by JSON call.
Posted on 2016-10-28
Need to retrieve and save or display an image file (usually .jpg or .pdf) returned by a call to a secure outside server. I'm used to retrieving data arrays in this way (content-type application/xml and application/json), but have never had to deal with a file or image (content-type application/octet-stream).
I can get the return, but don't know how to process it using PHP. Here is an example of the returned info:
HTTP/1.1 200 OK Cache-Control: no-cache Pragma: no-cache Content-Length: 228863 Content-Type: application/octet-stream Expires: -1 Server: Microsoft-IIS/7.5 Content-Disposition: attachment; filename=picture.jpg X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET Date: Fri, 28 Oct 2016 19:43:37 GMT ����JFIF``��XExifMM*GFGIc�i2��>� ... [228K of data].
Can anyone provide pointers?