From 3e1713e3eb985c16df4a20b2bd302bd1f6772dd1 Mon Sep 17 00:00:00 2001 From: divinity76 Date: Mon, 10 Apr 2023 13:40:15 +0200 Subject: [PATCH] fix loop early return, and workaround bug --- tinyfilemanager.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tinyfilemanager.php b/tinyfilemanager.php index 216d4e8..7840cb6 100644 --- a/tinyfilemanager.php +++ b/tinyfilemanager.php @@ -969,7 +969,12 @@ if (!empty($_FILES) && !FM_READONLY) { if ($out) { $in = @fopen($tmp_name, "rb"); if ($in) { - stream_copy_to_stream($in, $out); + if (PHP_VERSION_ID < 80009) { + // workaround https://bugs.php.net/bug.php?id=81145 + while (!in_array($buff = fread($in, 4096), array("", false), true)) { fwrite($out, $buff); } + } else { + stream_copy_to_stream($in, $out); + } $response = array ( 'status' => 'success', 'info' => "file upload successful"