ID:               31350
 Updated by:       [EMAIL PROTECTED]
 Reported By:      gibspam at carnation dot hu
-Status:           Open
+Status:           Bogus
 Bug Type:         Filesystem function related
 Operating System: Redhat Linux 7.1-7.3
 PHP Version:      4.3.10
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

.


Previous Comments:
------------------------------------------------------------------------

[2004-12-30 11:59:12] gibspam at carnation dot hu

Description:
------------
I write a script which reads a file from STDIN, and writes it out the
content of it to a new file. It worked fine with php 4.3.4, but when I
upgraded to any newer version, then it failed to read the whole file
from stdin. I expected to read the file into a 128000 bytes buffer but
it reads only 8192 bytes instead of 128000 bytes.

Reproduce code:
---------------
<?
$file_length = 6596594;
define("UPLOAD_BUFFER",128000);

if (!$fp = fopen("test.data","w"))
{
                die("file open error");
}

$count =  (($file_length / UPLOAD_BUFFER));
echo "\nmax i should be: ".$count;
for ($i = 1; $i < $count; $i ++) {
        $str = fread(STDIN, UPLOAD_BUFFER);
        echo "\ni: ".$i." length:".strlen($str);
        fwrite($fp, $str);
}

$remainder = $file_length % UPLOAD_BUFFER;

if (0 != $remainder) {
        $str = fread(STDIN, $remainder);
        echo "\nlast length:".strlen($str);
        fwrite($fp, fread(STDIN, $remainder));
}

fclose($fp);
?>


Expected result:
----------------
If I run my script with this command:
php -q ./my.php < file_with_size_of_6596594_bytes.bin

I expect to get a new file created (test.data), with the same content
as the file_with_size_of_6596594_bytes.bin.

Actual result:
--------------
As a result a new file created (test.data), which is 425984 bytes
long.

425984=51*8192+8192

But, it shuld be

6596594=51*128000+68594




------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=31350&edit=1

Reply via email to