note 86684 deleted from function.header by danbrown

From: Date: Sun, 07 Dec 2008 17:54:13 +0000
Subject: note 86684 deleted from function.header by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-147787@lists.php.net to get a copy of this message
Note Submitter: tom ---- Various scripts suggested here attempt to deliver a file for download to a client. Handling http protocol features such as HTTP_RANGE is not trivial; neither is handling flow control with the server, memory and time limits when the files are large. An alternative is to let the web server handle http by redirecting to the file in question. It's not uncommon e.g. http://www.apple.com/downloads/macosx/ does this. A PHP script can do any checks needed (security, authentication, validate the file) and any other tasks before calling header("Location $urltofile"); I tested this with apache. Interrupt/resume download works. The server's mime type configuration will determine client behavior. For apache, if defaults in mime.types are not suitable, configuration directives for mod_mime could go in a .htaccess file in the directory of the file to download. If really necessary, these could even by written by the PHP script before it redirects.

« previous php.notes (#147787) next »