diff --git a/ext/cron_uploader/main.php b/ext/cron_uploader/main.php index 5f67f909..820ec259 100644 --- a/ext/cron_uploader/main.php +++ b/ext/cron_uploader/main.php @@ -289,16 +289,23 @@ class CronUploader extends Extension // Create $newDir = $this->root_dir; - // Determine which dir to move to - if ($corrupt) { - // Move to corrupt dir - $newDir .= "/failed_to_upload/"; - $info = "ERROR: Image was not uploaded."; - } else { - $newDir .= "/uploaded/"; - $info = "Image successfully uploaded. "; - } - + $relativeDir = dirname(substr($path, strlen($this->root_dir) + 7)); + + // Determine which dir to move to + if ($corrupt) { + // Move to corrupt dir + $newDir .= "/failed_to_upload/".$relativeDir; + $info = "ERROR: Image was not uploaded."; + } + else { + $newDir .= "/uploaded/".$relativeDir; + $info = "Image successfully uploaded. "; + } + $newDir = str_replace ( "//", "/", $newDir."/" ); + + if (!is_dir($newDir)) + mkdir ( $newDir, 0775, true ); + // move file to correct dir rename($path, $newDir.$filename);