note 111027 deleted from function.stream-copy-to-stream by googleguy
| From: | googleguy@php.net | Date: | Tue, 08 Jan 2013 11:03:32 +0000 |
| Subject: | note 111027 deleted from function.stream-copy-to-stream by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-192835@lists.php.net to get a copy of this message | ||
Note Submitter: singh at devilcode dot org
----
My post refers to the solution by felix dot nensa at gmail dot com.
stream_copy_to_stream() has a negative sideeffect when u use a "maxlength".
If your SourceStream has for example 8000 byte, and u read in 4096 chunks. So the first run will
copy 4096 chunks wich works quite fine. But in the second run, you would expect it to only add the
rest 3904 bytes. This is were the "bug" happens. stream_copy_to_stream() will copy the
rest 3904 bytes + the differ of chunksize-restdata (192 bytes) will be added as 0 bytes onto the
stream.
If you use the solution via fwrite/fget shown by felix dot nensa at gmail dot com you dont hav this
problem at all.