note 42489 added to function.base64-decode
| From: | tekrat at nospamplease dot 2d dot com | Date: | Tue, 18 May 2004 18:50:42 +0000 |
| Subject: | note 42489 added to function.base64-decode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-69787@lists.php.net to get a copy of this message | ||
I needed to read files in and out of a database but I could only store string and numaeric values
due to server limitations. So I created these function to encode and decode files.
<?
function textEncodeFile($myFileLocation){
$handle = fopen($myFileLocation,'rb');
$file_content = fread($handle,filesize($myFileLocation));
fclose($handle);
return base64_encode($file_content);
}
function binaryEncodeFile($myText, $saveLocation){
$ifp = fopen( $saveLocation, "wb" );
fwrite( $ifp, base64_decode( $myText ) );
fclose( $ifp );
}
?>
BTW: This is not UUEncoding but it works very similar.
----
Manual Page -- http://www.php.net/manual/en/function.base64-decode.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+42489
Delete -- http://master.php.net/manage/user-notes.php?action=delete+42489&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+42489&report=yes
Search -- http://master.php.net/manage/user-notes.php