From d5ecd60790aef9cac0f8178dc1bb986c756a68df Mon Sep 17 00:00:00 2001 From: prototrip Date: Sat, 7 Aug 2021 14:33:46 +0300 Subject: [PATCH] added an image file for transfer and chagnes to api --- api.php | 13 ++++++------- wifi.png | Bin 0 -> 710 bytes 2 files changed, 6 insertions(+), 7 deletions(-) create mode 100644 wifi.png diff --git a/api.php b/api.php index 2beb383..16b6297 100644 --- a/api.php +++ b/api.php @@ -9,8 +9,7 @@ $api = new App('http://0.0.0.0:3500'); $api->count = 4; // process count $api->any('/', function ($requst) { - $filename = "test.txt"; - $file_contents = file_get_contents($filename); + $filename = "wifi.png"; $attachment_location = $_SERVER["DOCUMENT_ROOT"] . $filename; $headers = []; @@ -18,15 +17,15 @@ $api->any('/', function ($requst) { if (file_exists($attachment_location)) { $headers[] = $_SERVER["SERVER_PROTOCOL"] . " 200 OK"; $headers[] = "Cache-Control: public"; - $headers[] = "Content-Type: application/text"; + $headers[] = "Content-Type: application/png"; $headers[] = "Content-Transfer-Encoding: Binary"; $headers[] = "Content-Length:".filesize($attachment_location); - $headers[] = "Content-Disposition: attachment; filename={$file_contents}"; - // die(); + $headers[] = "Content-Disposition: attachment; filename={$filename}"; + die(); } else { - // die("Error: File not found."); + die("Error: File not found."); } - return new Response(200, $headers, $file_contents); + return new Response(200, $headers, $filename); }); $api->get('/hello/{name}', function ($requst, $name) { diff --git a/wifi.png b/wifi.png new file mode 100644 index 0000000000000000000000000000000000000000..6255e102e77f0f8df88f474373181158193d41f4 GIT binary patch literal 710 zcmV;%0y+JOP)uvKffO%jezFk#=Yqe{wurkezf zy5r{d)$w|Q-iP`EK+??_y|naNOvmU6 zeqa8r|K7ePZSG&+i2L`9eD&X25S&{`8DR01_0KJu9#jj5cc(x2KaA?X8P@)s+M2V? zYNU8SpOk-JKZ3NTo=4VpEaH82ZvM4@vex&XTkJ6dloonjqkr<$yhpehy#LC&#h4!6 z9@0nZ34UjO?VmL37F*+Ays?8R`X~Pv-Y?;)1Ft#Ua$5gLPw@Nlel+(PY)Du0#t!Rl z>B@W8AN<>~9=u6F0Z}fpe!QCdFU+lAX(NAiN`9>`_-MBORPm@cudW;M?-}_`{&~Af sGpfI4wxy(d(;s~B!3Q6F@Mq+I1F)vxFP`Io>;M1&07*qoM6N<$f>IrBdjJ3c literal 0 HcmV?d00001