1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-01 11:30:16 +02:00

Add more detailed exception messages for NotWritableException

This commit is contained in:
Oliver Vogel
2023-12-23 10:28:49 +01:00
parent 03aa19cac4
commit b58b4b0e43

View File

@@ -28,6 +28,21 @@ class File implements FileInterface
*/
public function save(string $filepath): void
{
$dir = pathinfo($filepath, PATHINFO_DIRNAME);
if (!is_dir($dir)) {
throw new NotWritableException(
"Can't write image to path. Directory does not exist."
);
}
if (!is_writable($dir)) {
throw new NotWritableException(
"Can't write image to path. Directory is not writable."
);
}
// write date
$saved = @file_put_contents($filepath, (string) $this);
if ($saved === false) {
throw new NotWritableException(