mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Make readBase64 an instance method
Leverage the existing code in File::read() and simply add in chunking and base64 encoding.
This commit is contained in:
parent
dfdde954ea
commit
4a4ca7c8d4
2 changed files with 5 additions and 9 deletions
|
@ -1385,7 +1385,8 @@ class CakeEmail {
|
|||
* @return string File contents in base64 encoding
|
||||
*/
|
||||
protected function _readFile($file) {
|
||||
return File::readAndBase64Encode($file);
|
||||
$f = new File($file);
|
||||
return $f->readBase64();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -181,18 +181,13 @@ class File {
|
|||
}
|
||||
|
||||
/**
|
||||
* Read the file contents and return a base64 version of the file contents.
|
||||
* Return the contents of this File as a base64 version of the file contents.
|
||||
*
|
||||
* @param string $file The file to read.
|
||||
* @return string File contents in base64 encoding
|
||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::readAndBase64Encode
|
||||
*/
|
||||
public static function readAndBase64Encode($file) {
|
||||
$handle = fopen($file, 'rb');
|
||||
$data = fread($handle, filesize($file));
|
||||
$data = chunk_split(base64_encode($data));
|
||||
fclose($handle);
|
||||
return $data;
|
||||
public function readBase64() {
|
||||
return chunk_split(base64_encode($this->read()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue