From 107e1e4d1f7d7ec3fe26dbfcbdba95ea24e6bd56 Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Thu, 10 Aug 2023 17:59:15 -0400 Subject: [PATCH] read file --- www-api/app/Controllers/WrenchMedia.php | 29 +++++++++++++++++++------ 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/www-api/app/Controllers/WrenchMedia.php b/www-api/app/Controllers/WrenchMedia.php index bc1f956f..280963a1 100644 --- a/www-api/app/Controllers/WrenchMedia.php +++ b/www-api/app/Controllers/WrenchMedia.php @@ -30,13 +30,28 @@ class WrenchMedia extends BaseController public function apigate(){ - $file = __DIR__ . DIRECTORY_SEPARATOR . "books.png"; - $fileData = exif_read_data($file); - ob_start(); - header("Content-Type: " . $fileData["MimeType"]); - header("Content-Length: " . $fileData["FileSize"]); - readfile($file); - ob_end_flush(); +// $file = __DIR__ . DIRECTORY_SEPARATOR . "books.png"; +// $fileData = exif_read_data($file); +// ob_start(); +// header("Content-Type: " . $fileData["MimeType"]); +// header("Content-Length: " . $fileData["FileSize"]); +// readfile($file); +// ob_end_flush(); + + $file = 'books.png'; + + if (file_exists($file)) { + header('Content-Description: File Transfer'); + header('Content-Type: application/octet-stream'); + header('Content-Disposition: attachment; filename="'.basename($file).'"'); + header('Expires: 0'); + header('Cache-Control: must-revalidate'); + header('Pragma: public'); + header('Content-Length: ' . filesize($file)); + readfile($file); + exit; + } + } public function apigate33(){