PHP header attach AVI-file

夙愿已清 提交于 2019-11-29 17:36:17

Add this line before readfile():

 header("Content-Length: " . filesize($file_path));

Test it,i think this will work!

header ( "Pragma: public" );
header ( "Expires: 0" );
header ( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
header ( "Content-Type: application/force-download" );
header ( "Content-Type: application/octet-stream" );
header ( "Content-Type: application/download" );
header ( "Content-Disposition: attachment; filename=\"" . $file_path . "\";" );
header ( "Content-Transfer-Encoding: binary " );
header ( "Content-type: " . $ctype);

$chunksize = 1 * (1024 * 1024); // how many bytes per chunk 
if ($size > $chunksize) { 
  $handle = fopen($file_path, 'rb'); 
  $buffer = ''; 
  while (!feof($handle)) { 
    $buffer = fread($handle, $chunksize); 
    echo $buffer; 
    ob_flush(); 
    flush(); 
  } 
  fclose($handle); 
  exit();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!