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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: cquadalti at libero dot it
New email:
PHP Version: OS:

 

 [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 21:01:32 2024 UTC