Descarregamento de força, a partir do arquivo php
Estou tentando baixar um arquivo .mp4. (cerca de 1,3 GB de tamanho). Eu estou usando o seguinte:
<?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);
Eu abro meu arquivo php, e o firefox aparece com o menu "quero salvar". Tamanho parece certo. Eu pressiono Salvar como na minha área de trabalho. O arquivo final baixado, lista como um tamanho aleatório, em torno de 400MB (330, 463 e 440).
Cabeçalhos de resposta são:
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