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

 ID:                 54518
 User updated by:    gabriel at justbull dot com
 Reported by:        gabriel at justbull dot com
 Summary:            filesize and reafile incosistencies with pdf file
-Status:             Feedback
+Status:             Closed
 Type:               Bug
 Package:            Filesystem function related
 Operating System:   Centos 5.5
 PHP Version:        5.3.6
 Block user comment: N
 Private report:     N

 New Comment:

Closing


Previous Comments:
------------------------------------------------------------------------
[2011-04-13 15:14:13] gabriel at justbull dot com

Ok, an included file had line returns after the ?>. I guess what threw
me in the 

wrong direction is that it was still working fine with some PDFs.

------------------------------------------------------------------------
[2011-04-13 10:44:50] [email protected]

Almost certainly bogus, but in any case, what is this extra data that's
causing the discrepancy? What's its place in the output stream?



Most likely there's whitespace or a BOM mark in the script (or an
included script).

------------------------------------------------------------------------
[2011-04-12 21:55:16] gabriel at justbull dot com

Description:
------------
With some PDF files (not all), the filesize function report a file size
that is 

not representative of the size of the file produced by readfile.



The filesize gives the same filesize as the original file. But the
readfile 

doesn't give the exact same content as the original file, making it
slightly 

bigger.



This results in some part of the file being cut if you include the
filesize in the 

header.



I can reproduce this bug on 2 servers,

Test script:
---------------
header('Content-Type: application/pdf');

header("Content-Length: ".filesize($file));

readfile($file);

exit();



// THIS CODE PRODUCE THE SAME PROBLEM 



ob_start();

readfile($file);

$output = ob_get_clean();

header('Content-Type: application/pdf');

header("Content-Length: ".strlen($output));

echo $output;

exit();

Expected result:
----------------
Expect the filesize to return the right filesize. Or the readfile to
output the 

exactly same content as the original file. 

Actual result:
--------------
The filesize function report a file size that is not representative of
the size of 

the file produced by readfile.


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



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

Reply via email to