I'm trying to get a zip file to automatically download:
$attachment_location = "https://dev.com/daily/updates/com_prog_v1_8_0.zip";
if (file_exists($attachment_location)) {
header($_SERVER["SERVER_PROTOCOL"] . " 200 OK");
header("Cache-Control: public"); // needed for internet explorer
header("Content-Type: application/zip");
header("Content-Transfer-Encoding: Binary");
header("Content-Length:".filesize($attachment_location));
header("Content-Disposition: attachment; filename=com_prog_v1_8_0.zip");
readfile($attachment_location);
die();
}
I've tried to link in the browser and the file downloads without a problem. I'm not sure what to do to debug it. As far as I can tell it is right. I'm expecting to run this file (and index.php file) and have it kick off the download of the file. I've had a good look at the other posts and can't figure out the problem.
I've also tried just
file_put_contents("com_prog_v1_8_0.zip", fopen("https://dev.com/daily/updates/com_prog_v1_8_0.zip", 'r'));
but that also throws
Error: File not found.
Any ideas what I can do to track down the problem would be great. I'm sure it must be something I can't see for looking!
thansk