From e1aefb78abe2972bf166b340ef72c1cd615e97d9 Mon Sep 17 00:00:00 2001 From: Matthew Barbour Date: Tue, 2 Jun 2020 17:54:51 -0500 Subject: [PATCH] Fix for cron uploader issue with root paths ending in a slash --- ext/cron_uploader/main.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ext/cron_uploader/main.php b/ext/cron_uploader/main.php index 23be8653..48395d90 100644 --- a/ext/cron_uploader/main.php +++ b/ext/cron_uploader/main.php @@ -364,7 +364,13 @@ class CronUploader extends Extension private function move_uploaded(string $path, string $filename, string $output_subdir, bool $corrupt = false) { - $relativeDir = dirname(substr($path, strlen(CronUploaderConfig::get_dir()) + 7)); + $rootDir = CronUploaderConfig::get_dir(); + $rootLength = strlen($rootDir); + if ($rootDir[$rootLength-1]=="/"||$rootDir[$rootLength-1]=="\\") { + $rootLength--; + } + + $relativeDir = dirname(substr($path, $rootLength + 7)); if ($relativeDir==".") { $relativeDir = "";