mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-18 07:29:51 +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
|
* @return string File contents in base64 encoding
|
||||||
*/
|
*/
|
||||||
protected function _readFile($file) {
|
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
|
* @return string File contents in base64 encoding
|
||||||
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::readAndBase64Encode
|
* @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::readAndBase64Encode
|
||||||
*/
|
*/
|
||||||
public static function readAndBase64Encode($file) {
|
public function readBase64() {
|
||||||
$handle = fopen($file, 'rb');
|
return chunk_split(base64_encode($this->read()));
|
||||||
$data = fread($handle, filesize($file));
|
|
||||||
$data = chunk_split(base64_encode($data));
|
|
||||||
fclose($handle);
|
|
||||||
return $data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue