mirror of
				https://github.com/prasathmani/tinyfilemanager.git
				synced 2025-11-03 20:05:47 +01:00 
			
		
		
		
	use stream_copy_to_stream (#1014)
* 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~) * fix loop early return, and workaround bug * use feof ref https://github.com/prasathmani/tinyfilemanager/issues/1016#issuecomment-1502081506
This commit is contained in:
		@@ -969,7 +969,12 @@ if (!empty($_FILES) && !FM_READONLY) {
 | 
				
			|||||||
                if ($out) {
 | 
					                if ($out) {
 | 
				
			||||||
                    $in = @fopen($tmp_name, "rb");
 | 
					                    $in = @fopen($tmp_name, "rb");
 | 
				
			||||||
                    if ($in) {
 | 
					                    if ($in) {
 | 
				
			||||||
                        while ($buff = fread($in, 4096)) { fwrite($out, $buff); }
 | 
					                        if (PHP_VERSION_ID < 80009) {
 | 
				
			||||||
 | 
					                            // workaround https://bugs.php.net/bug.php?id=81145
 | 
				
			||||||
 | 
					                            while (!feof($in)) { fwrite($out, fread($in, 4096)); }
 | 
				
			||||||
 | 
					                        } else {
 | 
				
			||||||
 | 
					                            stream_copy_to_stream($in, $out);
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
                        $response = array (
 | 
					                        $response = array (
 | 
				
			||||||
                            'status'    => 'success',
 | 
					                            'status'    => 'success',
 | 
				
			||||||
                            'info' => "file upload successful"
 | 
					                            'info' => "file upload successful"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user