|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-08-06 13:19 UTC] jani@php.net
[2009-08-14 01:00 UTC] php-bugs at lists dot php dot net
[2009-10-11 08:49 UTC] phpspam at ethaniel dot com
[2009-10-11 09:43 UTC] phpspam at ethaniel dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 18:00:01 2025 UTC |
Description: ------------ Hi. I have a PHP app where I generate a PDF file, using jasperreports, and then mail this file to a subscriber. I use curl and the CURLOPT_FILE option to get the pdf file. As soon as I finish getting the file, it reports a size that is always an exact multiple of 4Kbytes, even when the file is bigger than what PHP reports. Reproduce code: --------------- Code with error is ... -- <?php $ch = curl_init("http://www.google.com"); $tmpfname = tempnam(sys_get_temp_dir(), "IPV"); $fpOutput = fopen($tmpfname, "wb"); curl_setopt($ch, CURLOPT_FILE, $fpOutput); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); fclose($fpOutput); echo "filesize: $tmpfname: " . filesize($tmpfname) . "\n"; ?> -- Code without error is ... -- <?php $tmpfname = tempnam(sys_get_temp_dir(), "IPV"); $fpOutput = fopen($tmpfname, "wb"); $ch = curl_init("http://www.google.com"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_WRITEFUNCTION, 'read_body'); curl_exec($ch); curl_close($ch); fclose($fpOutput); echo "filesize: $tmpfname: " . filesize($tmpfname) . "\n"; die(); function read_body($ch, $string) { global $fpOutput; $length = strlen($string); if (fwrite($fpOutput, $string) === FALSE) { echo "Cannot write to file"; die(); } return $length; } ?> Expected result: ---------------- The second piece of code reported in this bug report gives the correct file size. The first piece of code saves the file with the correct size but doesn't report it correctly. This was not happening until I upgraded to PHP 5.2.10 from a previous version that I don't remember. :( Hope you can find inside what is going on. Best regards and thanks for a great piece of software. Mauricio Ramirez Actual result: -------------- The first piece of code reports 4096 bytes for the google.com page. The second piece of code reports (today!) 6672 bytes which is the right size.