Index: kernel/db/db_event_handler.php =================================================================== --- kernel/db/db_event_handler.php (revision 12948) +++ kernel/db/db_event_handler.php (working copy) @@ -2352,7 +2352,7 @@ $fields = $this->Application->getUnitOption($event->Prefix, 'Fields'); $upload_dir = $fields[ $this->Application->GetVar('field') ]['upload_dir']; - if (!is_writable($tmp_path) || !is_writable(FULL_PATH . $upload_dir)) { + if (!is_writable($tmp_path)) { // 500 Internal Server Error // check both temp and live upload directory header('HTTP/1.0 500 Write permissions not set on the server'); Index: kernel/utility/formatters/upload_formatter.php =================================================================== --- kernel/utility/formatters/upload_formatter.php (revision 12948) +++ kernel/utility/formatters/upload_formatter.php (working copy) @@ -44,7 +44,8 @@ $this->DestinationPath = $options['upload_dir']; $this->FullPath = FULL_PATH.$this->DestinationPath; } - + $this->CheckFolder(); + // SWF Uploader if (is_array($value) && isset($value['tmp_ids'])) { if ($value['tmp_deleted']) { @@ -315,6 +316,33 @@ return $new_name; } + function CheckFolder($path = false) + { + if ($path === false) { + $path = $this->FullPath; + } + + $result = true; + if (!file_exists($path) || !is_dir($path)) { + $parent_path = preg_replace('/\/[^\/]+\/?$/', '', $path); + $result = $this->CheckFolder($parent_path); + if ($result) { + $result = mkdir($path); + if ($result) { + chmod($path, 0777); + $cvsignore = fopen($path.'/.cvsignore', 'w'); + fwrite($cvsignore, '*.*'); + fclose($cvsignore); + chmod($path.'/.cvsignore', 0777); + } + else { + trigger_error('Cannot create directory '.$path.' for file upload', E_USER_WARNING); + } + } + } + + return $result; + } } class kPictureFormatter extends kUploadFormatter Index: units/helpers/image_helper.php =================================================================== --- units/helpers/image_helper.php (revision 12948) +++ units/helpers/image_helper.php (working copy) @@ -101,6 +101,21 @@ if ($needs_resize || array_intersect(array_keys($params), $transform_keys)) { // resize required OR watermarking required -> change resulting image name ! $dst_image = preg_replace('/^'.preg_quote($src_path, '/').'(.*)\.(.*)$/', $src_path . DIRECTORY_SEPARATOR . 'resized\\1_' . crc32(serialize($params)) . '.\\2', $src_image); + + $dst_dir = dirname($dst_image); + if (!file_exists($dst_dir) || !is_dir($dst_dir)) { + if (!mkdir($dst_dir)) { + trigger_error('Cannot create resized directory under '.$src_path.'', E_USER_WARNING); + } + else { + chmod($dst_dir, 0777); + $cvsignore = fopen($dst_dir.'/.cvsignore', 'w'); + fwrite($cvsignore, '*.*'); + fclose($cvsignore); + chmod($dst_dir.'/.cvsignore', 0777); + } + } + if (!file_exists($dst_image) || filemtime($src_image) > filemtime($dst_image)) { // resized image not available OR should be recreated due source image change $params['dst_image'] = $dst_image;