From c6c7915e526e13558eedb1b0ed8ce08eb80c5866 Mon Sep 17 00:00:00 2001 From: prototrip Date: Sat, 7 Aug 2021 14:37:55 +0300 Subject: [PATCH] added an image file for transfer and chagnes to api --- api.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/api.php b/api.php index 16b6297..59230ee 100644 --- a/api.php +++ b/api.php @@ -10,16 +10,13 @@ $api->count = 4; // process count $api->any('/', function ($requst) { $filename = "wifi.png"; - - $attachment_location = $_SERVER["DOCUMENT_ROOT"] . $filename; $headers = []; - if (file_exists($attachment_location)) { - $headers[] = $_SERVER["SERVER_PROTOCOL"] . " 200 OK"; + if (file_exists($filename)) { $headers[] = "Cache-Control: public"; - $headers[] = "Content-Type: application/png"; + $headers[] = "Content-Type: image/png"; $headers[] = "Content-Transfer-Encoding: Binary"; - $headers[] = "Content-Length:".filesize($attachment_location); + $headers[] = "Content-Length:".filesize($filename); $headers[] = "Content-Disposition: attachment; filename={$filename}"; die(); } else {