note 42489 deleted from function.base64-decode by tomsommer
| From: | tomsommer@php.net | Date: | Tue, 18 May 2004 22:32:31 +0000 |
| Subject: | note 42489 deleted from function.base64-decode by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-69807@lists.php.net to get a copy of this message | ||
Note Submitter: tekrat@nospamplease.2d.com
----
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.