You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used a (previously errorneous) script that should attach all files within a directory to a PHPMailer object using addAttachment. The script did unfortunately not exclude paths to (sub) directories. Here is what happens:
If you use the addAttachment function and pass a directory path rather than a file path, then
the file_get_contents function produces a Notice file_get_contents(): Read of 8192 bytes failed with errno=21 Is a directory in ...
A zero byte attachment with the directory's name as file name is added to the email.
Code to reproduce
$mail->addAttachment('/some/path');
Suggestion
The function fileIsAccessible uses file_exists to check whether a file path is valid. But this function returns true if the given path is a file or a directory (https://www.php.net/manual/en/function.file-exists.php). The problem could be solved by using is_file instead.
The text was updated successfully, but these errors were encountered:
Problem description
I used a (previously errorneous) script that should attach all files within a directory to a PHPMailer object using
addAttachment
. The script did unfortunately not exclude paths to (sub) directories. Here is what happens:If you use the
addAttachment
function and pass a directory path rather than a file path, thenfile_get_contents
function produces a Noticefile_get_contents(): Read of 8192 bytes failed with errno=21 Is a directory in ...
Code to reproduce
$mail->addAttachment('/some/path');
Suggestion
The function
fileIsAccessible
usesfile_exists
to check whether a file path is valid. But this function returns true if the given path is a file or a directory (https://www.php.net/manual/en/function.file-exists.php). The problem could be solved by usingis_file
instead.The text was updated successfully, but these errors were encountered: