php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32970 readfile does not output more than ~ 2MB of data
Submitted: 2005-05-06 19:00 UTC Modified: 2005-05-06 21:31 UTC
From: flobee at gmail dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.0.4 OS: suse/debian/winXP
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: flobee at gmail dot com
New email:
PHP Version: OS:

 

 [2005-05-06 19:00 UTC] flobee at gmail dot com
Description:
------------
when file lager than ~ 2MB i only get ~2MB send to the header

eg:
if($result_size = @readfile( $file_to_download) ) { ; 
     $msg = _DOWNLOAD_SUCCESSFUL;
} else {
     $msg = _ERROR_COULDNOTCOMPLETETHEFILE;
}

this is since php5 beta and have no idea why, no error no other messages.
execution time and memorylimit are set very high for testing. no changes.



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-06 20:39 UTC] tony2001@php.net
Fixed in CVS several weeks ago.
 [2005-05-06 21:31 UTC] flobee at gmail dot com
hmmm. my hoster still has this bug, 
i just reported this as "note" for other users to have a work around.

<?php
function readfile_chunked($filename,$retbytes=true) {
   $chunksize = 1*(1024*1024); // how many bytes per chunk
   $buffer = '';
   $cnt =0;
   // $handle = fopen($filename, 'rb');
   $handle = fopen($filename, 'rb');
   if ($handle === false) {
       return false;
   }
   while (!feof($handle)) {
       $buffer = fread($handle, $chunksize);
       echo $buffer;
       if ($retbytes) {
           $cnt += strlen($buffer);
       }
   }
       $status = fclose($handle);
   if ($retbytes && $status) {
       return $cnt; // return num. bytes delivered like readfile() does.
   }
   return $status;

}
?> 

kind regards 
flobee
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Nov 24 22:01:33 2024 UTC