php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26877 fread() with URL reads only part of file
Submitted: 2004-01-12 04:30 UTC Modified: 2004-01-12 05:28 UTC
From: dinklage at dinklage dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 4.3.4 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dinklage at dinklage dot com
New email:
PHP Version: OS:

 

 [2004-01-12 04:30 UTC] dinklage at dinklage dot com
Description:
------------
Using fread() with URL returns only a part of the file:

eg:
reading http://schreiners-buero.de/sbinfo.htm with
25170 Byte is only 2550 Byte

Reproduce code:
---------------
$url='http://schreiners-buero.de/sbinfo.htm';
$fp = fopen($url,'rb');
$code = fread($fp,4000000);
fclose($fp);
echo "<p>length ".strlen($code)."  </p>";
$code2=file_get_contents($url);
echo "<p>length ".strlen($code2)."  </p>";
exit;



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-12 05:28 UTC] eru@php.net
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

from http://www.php.net/fread 

<?php
$handle = fopen(\"http://www.example.com/\", \"rb\");
$contents = \"\";
do {
   $data = fread($handle, 8192);
   if (strlen($data) == 0) {
       break;
   }
   $contents .= $data;
} while (true);
fclose($handle);
?>

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 10:01:33 2025 UTC