Linked Questions

Popular Questions

PHP issue with getting a redirect to work

Asked by At

I'm trying to get a zip file to automatically download:

            $attachment_location =  "";

            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-Disposition: attachment;");


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("", fopen("", '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!


Related Questions