read.php 498 B

123456789101112131415161718
  1. <?php
  2. $file_path = "./1.mp4"; //视频文件地址
  3. ob_end_clean();
  4. ob_start();
  5. //打开文件
  6. $handler = fopen($file_path, 'rb');
  7. $file_size = filesize($file_path);
  8. //声明头信息
  9. Header("Content-type: application/octet-stream");
  10. Header("Accept-Ranges: bytes");
  11. Header("Accept-Length: " . $file_size);
  12. Header("Content-Disposition: attachment; filename=" . basename($file_path));
  13. // 输出文件内容
  14. $oct_data = fread($handler, $file_size);
  15. fclose($handler);
  16. ob_end_flush();
  17. return $oct_data;