I'm attempting to download a .mp4 file. (about 1.3GB size). I'm using following:
<?php
$path = "video.mp4";
header('Accept-Ranges: bytes'); // For download resume
header('Cache-Control: must-revalidate, post-check=0, pre-check=0' );
header('Content-Description: File Transfer' );
header('Content-Disposition: attachment; filename="'.basename( $path ).'"' );
header('Content-Length: ' . filesize($path)); // File size
header('Content-Transfer-Encoding: binary'); // For Gecko browsers mainly
header('Content-Type: application/octet-stream' );
header('Expires: 0' );
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($path)) . ' GMT');
header('Pragma: no-cache' );
ob_clean();
flush();
readfile($path);
I open my php file, and firefox pops up with the "want to save" menu. Size looks right. I press Save As, to my desktop. The final downloaded file, lists as a random size, around 400MB (330, 463 and 440).
Response Headers are:
Connection: Keep-Alive
Content-Disposition: attachment; filename="//www.frederikspang.dk/elevgallavideo.mp4"
Content-Length: 1422778850
Content-Type: video/mp4
Date: Sun, 30 Jun 2013 22:12:30 GMT
Keep-Alive: timeout=10, max=50
Pragma: public
Server: Apache
content-transfer-encoding: binary