php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #4516 Filesystem Functions bug
Submitted: 2000-05-19 05:11 UTC Modified: 2000-06-28 14:24 UTC
From: species at hem2 dot passagen dot se Assigned:
Status: Closed Package: Other
PHP Version: 4.0 Release Candidate 1 OS: Windows 2000
Private report: No CVE-ID: None
 [2000-05-19 05:11 UTC] species at hem2 dot passagen dot se
In PHP 4.0 RC 1 running under Windows 2000 / IIS as an ISAPI module:

using fread function to obtain contents of a binray file
returns only a part of a file. Piece of code I used:

<?php

$fd = fopen("test.jpg", "r");

$size = filesize("test.jpg");
echo "<br>Filesize is: " . $size;

$bdata = fread($fd, $size);

$fp = fopen("bla.jpg", "w");
fwrite($fp,$bdata);
fclose($fp);
fclose($fd);
?>

Length of text.jpg is 11755 bytes. After running the code
length of bla.jpg is 65 bytes.
Tries writing $bdata = fread($fd, filesize("test.jpg"));
Didn't work.
All examples i found at www.faqts.com use the same way to
obtain contents of file. One is found at:
http://www.faqts.com/knowledge-base/view.phtml/aid/161/fid/13/lang/

Thanks!

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-06-28 14:24 UTC] andi at cvs dot php dot net
In windows you need to use "rb" in order to open a binary fle.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 13:01:29 2024 UTC