Check whether path is file in DataPart::fromPath()
This commit is contained in:
parent
a9ffbf4ccf
commit
9e3670e140
@ -56,6 +56,10 @@ class DataPart extends TextPart
|
|||||||
$contentType = self::$mimeTypes->getMimeTypes($ext)[0] ?? 'application/octet-stream';
|
$contentType = self::$mimeTypes->getMimeTypes($ext)[0] ?? 'application/octet-stream';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (false === is_readable($path)) {
|
||||||
|
throw new InvalidArgumentException(sprintf('Path "%s" is not readable.', $path));
|
||||||
|
}
|
||||||
|
|
||||||
if (false === $handle = @fopen($path, 'r', false)) {
|
if (false === $handle = @fopen($path, 'r', false)) {
|
||||||
throw new InvalidArgumentException(sprintf('Unable to open path "%s".', $path));
|
throw new InvalidArgumentException(sprintf('Unable to open path "%s".', $path));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user