note 76701 rejected from function.header by nlopess
| From: | nlopess@php.net | Date: | Fri, 27 Jul 2007 11:46:44 +0000 |
| Subject: | note 76701 rejected from function.header by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-128974@lists.php.net to get a copy of this message | ||
Note Submitter: rip at rip-hq dot net
----
I've got a question. I have a file hosting site and I've run into a nice problem when
downloading files using the header function.
Here is the code I use for downloading the file
<?php
$file = "/path/to/file.ext";
header('Accept-Ranges: bytes');
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header('Content-type: ' . $fileDownloader->mime_get_type($file) . '\r\n'); //
Custom mime type function
header("Content-Length: ". filesize($file) . "\r\n");
header('Content-Disposition: attachment; filename="' . $v_name . '"');
header("Content-Transfer-Encoding: binary\n");
readfile($file);
?>
As far as downloads are concerned, everything download perfect. The only issue is that once the
download begins, that user can not do anything else on the website until the download is either
complete or canceled.
Any ideas?