| Conditions | 2 |
| Paths | 2 |
| Total Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | static function download($filename, $displayname) |
||
|
|
|||
| 9 | { |
||
| 10 | header("Content-type: application/octet-stream"); |
||
| 11 | header("Accept-Ranges: bytes"); |
||
| 12 | header("Accept-Length:" . filesize($filename)); |
||
| 13 | header("Content-Disposition: attachment; filename=" . $displayname); |
||
| 14 | |||
| 15 | $fp = fopen($filename, 'rb'); |
||
| 16 | ob_end_clean(); |
||
| 17 | ob_start(); |
||
| 18 | while(!feof($fp)) |
||
| 19 | { |
||
| 20 | $chunk_size = 1024 * 8; |
||
| 21 | echo fread($fp, $chunk_size); |
||
| 22 | ob_flush(); |
||
| 23 | } |
||
| 24 | fclose($fp); |
||
| 25 | ob_end_clean(); |
||
| 26 | } |
||
| 27 | } |
||
| 28 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.