note 111027 added to function.stream-copy-to-stream
| From: | singh at devilcode dot org | Date: | Tue, 08 Jan 2013 10:35:35 +0000 |
| Subject: | note 111027 added to function.stream-copy-to-stream | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-192832@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 69.147.83.199
Probable Submitter: 134.3.19.240
----
Manual Page -- http://php.net/manual/en/function.stream-copy-to-stream.php
Edit -- https://master.php.net/note/edit/111027
Del: integrated -- https://master.php.net/note/delete/111027/integrated
Del: useless -- https://master.php.net/note/delete/111027/useless
Del: bad code -- https://master.php.net/note/delete/111027/bad+code
Del: spam -- https://master.php.net/note/delete/111027/spam
Del: non-english -- https://master.php.net/note/delete/111027/non-english
Del: in docs -- https://master.php.net/note/delete/111027/in+docs
Del: other reasons-- https://master.php.net/note/delete/111027
Reject -- https://master.php.net/note/reject/111027
Search -- https://master.php.net/manage/user-notes.php