php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13426 fread not work
Submitted: 2001-09-25 04:54 UTC Modified: 2001-10-17 06:43 UTC
From: cquadalti at libero dot it Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 4.0.6 OS: Windows 2000 Professional
Private report: No CVE-ID: None
 [2001-09-25 04:54 UTC] cquadalti at libero dot it
function encode_file($sourcefile) {
 if (is_readable($sourcefile)) {
    $fd = fopen($sourcefile, "r");
    $contents .= fread($fd,filesize($sourcefile));
    $encoded = chunk_split(base64_encode($contents));
    fclose($fd);
 }
 return $encoded;
}
			
$source = $DOCUMENT_ROOT."/IMAGES/titolomail.gif";

encode_file($source);

fopen also don't work with "rb" option and system return a memory violation error

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-09-25 06:14 UTC] cquadalti at libero dot it
function encode_file($sourcefile) {
 if (is_readable($sourcefile)) {
    $fd = fopen($sourcefile, "r");
    $contents = fread($fd,filesize($sourcefile));
    $encoded = chunk_split(base64_encode($contents));
    fclose($fd);
 }
 return $encoded;
}

$source = $DOCUMENT_ROOT."/IMAGES/titolomail.gif";

encode_file($source);

fopen also don't work with "rb" option and system return a memory violation
error
 [2001-09-25 09:58 UTC] sniper@php.net
So what you're saying is that using fopen with 'rb' which is 
the only way to open files (on windows) in binary mode,
does not work? Is this the problem?

Because using 'r' only won't work with binary files, such
as .gif's.

--Jani



 [2001-10-17 06:43 UTC] sander@php.net
No feedback. Closing.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 16 06:01:31 2024 UTC