PHPMailer\PHPMailer
PHPMailer::encodeFile
Encode a file attachment in requested format. Returns an empty string on failure.
Method of the class: PHPMailer{}
No Hooks.
Returns
String.
Usage
// protected - for code of main (parent) or child class $result = $this->encodeFile( $path, $encoding );
- $path(string) (required)
- The full path to the file.
- $encoding(string)
- The encoding to use; one of
'base64','7bit','8bit','binary','quoted-printable'.
Default:self::ENCODING_BASE64
PHPMailer::encodeFile() PHPMailer::encodeFile code WP 7.0
protected function encodeFile($path, $encoding = self::ENCODING_BASE64)
{
try {
if (!static::fileIsAccessible($path)) {
throw new Exception(self::lang('file_open') . $path, self::STOP_CONTINUE);
}
$file_buffer = file_get_contents($path);
if (false === $file_buffer) {
throw new Exception(self::lang('file_open') . $path, self::STOP_CONTINUE);
}
$file_buffer = $this->encodeString($file_buffer, $encoding);
return $file_buffer;
} catch (Exception $exc) {
$this->setError($exc->getMessage());
$this->edebug($exc->getMessage());
if ($this->exceptions) {
throw $exc;
}
return '';
}
}