Skip to content

Commit e4a8675

Browse files
committed
Feat: send_file method introduced
1 parent 720b488 commit e4a8675

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/App.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ public static function send_response(
4848
return exit($response);
4949
}
5050

51+
public static function send_file($filename)
52+
{
53+
header('Content-Type: application/octet-stream');
54+
header('Content-Disposition: attachment; filename="' . basename($filename) . '"');
55+
header('Expires: 0');
56+
header('Cache-Control: must-revalidate');
57+
header('Pragma: public');
58+
header('Content-Length: ' . filesize($filename));
59+
readfile($filename);
60+
}
61+
5162
public static function set_csrf()
5263
{
5364
session_start();

0 commit comments

Comments
 (0)