Просмотр файла system/inc/include/download.php

Размер файла: 890B
  1. <?php
  2.  
  3. function downloads($filename,
  4. $name,
  5. $onshcms='application/octet-stream')
  6. {
  7. ob_end_clean();
  8. $unon = 0;
  9. $size = filesize($filename);
  10. $to = $size;
  11. header('Content-Length: ' .($to-$unon));
  12. if (isset($cr)) header($cr);
  13. header('Connection: close');
  14. header('Content-Type: ' . $onshcms);
  15. $f=fopen($filename, 'rb');
  16. header('Content-Disposition: attachment; filename="'.$name.'";');
  17. fseek($f, $$unon, SEEK_SET);
  18. $size=$to;
  19. $downloaded=0;
  20. while(!feof($f) and !connection_status() and ($downloaded<$size))
  21. {
  22. $block = min(1024*8, $size - $downloaded);
  23. echo fread($f, $block);
  24. $downloaded += $block;
  25. flush();
  26. }
  27. fclose($f);
  28. }
  29.  
  30.  
  31.  
  32.  
  33. ?>