I am making a call(PHP server) to an API and I can confirm that I am getting a response, my code at the point where I know I am getting a response is:
$binaryF = $rsObject->makeCall('get', "/JobData/{$_GET["jID"]}", "?format=bin");
//header("Pragma: public"); // required
//header("Content-Type: application/zip");
//header("Content-Disposition: attachment; filename=ss.zip");
//header("Content-Length: " . filesize($binaryF.length));
//header("Content-Transfer-Encoding: binary");
file_put_contents('C:\ss.zip', $binaryF);
If I keep the code as is and click on the link that takes me to the page with this code on it, ss.zip is created and I open it and confirm that it has the correct content. The data is coming from an API call on the first line and is basically a zip package. If I remove the comments and comment out the file_put_contents line then the browser opens a file save dialog box but if I save it the archive is 0 bytes?
How do I send the content to a browser after retrieving it from the api call? I do not want to save it to disk first, I want to send it to the browser making the request directly.
Thank you Jack
Ok. I changed it to:
header("Pragma: public"); // required
header("Content-Type: application/zip");
header("Content-Disposition: attachment; filename=ss.zip");
header("Content-Length: " . strlen($binaryF));
header("Content-Transfer-Encoding: binary");
and now it opens the file save. I save it and it is 8 K but when I try t oopen it I get a message of: "Windows cannot open the folder" It complains that the zip is invalid? At least I am getting somewhere, thanks for the help so far!