diff --git a/classes/core/obfhelpers.php b/classes/core/obfhelpers.php index 5028603..208d177 100644 --- a/classes/core/obfhelpers.php +++ b/classes/core/obfhelpers.php @@ -170,7 +170,24 @@ public static function image_resize($src, $dst, $width, $height) trigger_error('The source file does not exist', E_USER_WARNING); return false; } - if (!is_writeable(pathinfo($dst)['dirname'])) { + + // get destination directory and create if it doesn't exist + $dst_pathinfo = pathinfo($dst); + if (!is_dir($dst_pathinfo['dirname'])) { + mkdir($dst_pathinfo['dirname'], 0777, true); + echo $dst_pathinfo['dirname']; + } + + // make sure it exists now + if (!is_dir($dst_pathinfo['dirname'])) { + echo 'foo'; + trigger_error('Unable to create destination directory.', E_USER_WARNING); + return false; + } + + // and we can write to it + if (!is_writeable($dst_pathinfo['dirname'])) { + echo 'bar'; trigger_error('The destination directory is not writeable', E_USER_WARNING); return false; }