use stream_copy_to_stream

it's simpler, and should be faster.
For example, stream_copy_to_stream can use sendfile ( https://man7.org/linux/man-pages/man2/sendfile.2.html ) on operating systems supporting it, which is faster and use less RAM than fread()+fwrite() (because it avoids copying data to/from userland, doing the copy entirely in-kernel~)
This commit is contained in:
divinity76 2023-04-09 13:39:12 +02:00 committed by GitHub
parent 6a6eb8abec
commit f918b954b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -969,7 +969,7 @@ if (!empty($_FILES) && !FM_READONLY) {
if ($out) {
$in = @fopen($tmp_name, "rb");
if ($in) {
while ($buff = fread($in, 4096)) { fwrite($out, $buff); }
stream_copy_to_stream($in, $out);
$response = array (
'status' => 'success',
'info' => "file upload successful"