<?php
$file = dirname(__FILE__) . "/download_it.zip";
if (file_exists($file)) {
if (FALSE !== ($handler = fopen($file, 'r'))) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . basename($file));
header('Content-Transfer-Encoding: chunked'); //changed to chunked
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
//Send the content in chunks
while (false !== ($chunk = fread($handler, 4096))) {
echo $chunk;
}
}
exit;
}
echo "<h1>Content error</h1><p>The file does not exist!</p>";?>
Showing posts with label force download. Show all posts
Showing posts with label force download. Show all posts
Monday, August 19, 2013
PHP Script to force download big files using chunk
Subscribe to:
Posts (Atom)