note 45557 added to function.header

From: Date: Fri, 10 Sep 2004 16:34:17 +0000
Subject: note 45557 added to function.header
Groups: php.notes 
Request: Send a blank email to php-notes+get-76416@lists.php.net to get a copy of this message
I have a download script that uses HTTP headers to download files that are located outside of the web path (on a Linux web server). I was doing what was posted in the normal examples: $SRC_FILE = "/path/outside/web/server/test.txt"; $download_size = filesize($SRC_FILE); $filename = basename($SRC_FILE); header("Content-Type: application/octet-stream"); header("Content-Disposition: attachment; filename=$filename"); header("Accept-Ranges: bytes"); header("Content-Length: $download_size"); @readfile($SRC_FILE); But in Internet Explorer, whenever I would click the link to downlad, I could only save the file. If I tried opening the file directly, it gave an error about not being able to find the temporary file. After digging around for a while, I found the solution. You have to set the Cache-Control to private. So I added the following headers (on top/before the others): header("Pragma: public"); header("Expires: 0"); header("Cache-Control: private"); And now it works. I had a different Cache-Control setting before, and it wasn't working. So I'm certain that setting the Cache-Control to private is what fixed it. The server environment is Apache 1.3.29 with PHP 4.3.8 running over mod_ssl and using PHP sessions. Hope this helps someone! ---- Manual Page -- http://www.php.net/manual/en/function.header.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+45557 Delete -- http://master.php.net/manage/user-notes.php?action=delete+45557&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+45557&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#76416) next »