create dir if does not exist.

This commit is contained in:
Miroslav Šedivý 2019-12-26 16:29:07 +01:00
parent e155ad0ae4
commit 1a4e7dc049

View file

@ -138,6 +138,11 @@ class Image
$name, $ext, $md5
)->last_id();
// Ensure, that directories exists
if((!is_dir(self::IMAGES) && !mkdir(self::IMAGES)) || (!is_dir(self::THUMBS) && !mkdir(self::THUMBS))){
throw new Exception("Images / thumbnails directories could not be created.");
}
// Create path name
$name = dechex($id).self::random_str(3).".".$ext;
$path = self::IMAGES.$name;
@ -145,7 +150,7 @@ class Image
// Save path
if(!move_uploaded_file($_FILES['file']['tmp_name'], $path)){
throw new Exception("File cannot be written to image folders.");
throw new Exception("File cannot be written to image directory.");
}
// Create thumb