From 9078d83ee83154e32ed9c0668d806409f8d80637 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Thu, 7 Sep 2017 18:11:23 +0200 Subject: [PATCH] File option type file uses relative path Close #2404 --- .../install/files/lib/data/package/Package.class.php | 9 +++++++++ .../files/lib/system/option/FileOptionType.class.php | 9 +++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/wcfsetup/install/files/lib/data/package/Package.class.php b/wcfsetup/install/files/lib/data/package/Package.class.php index b0b49d56a6..e488a0c505 100644 --- a/wcfsetup/install/files/lib/data/package/Package.class.php +++ b/wcfsetup/install/files/lib/data/package/Package.class.php @@ -191,6 +191,15 @@ class Package extends DatabaseObject { $this->data['packageVersion'] = $packageVersion; } + /** + * Returns the absolute path to the package directory with a trailing slash. + * + * @return string + */ + public function getAbsolutePackageDir() { + return FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR . $this->packageDir)); + } + /** * Loads package requirements. */ diff --git a/wcfsetup/install/files/lib/system/option/FileOptionType.class.php b/wcfsetup/install/files/lib/system/option/FileOptionType.class.php index 75be6b8ca7..ad24d4d997 100644 --- a/wcfsetup/install/files/lib/system/option/FileOptionType.class.php +++ b/wcfsetup/install/files/lib/system/option/FileOptionType.class.php @@ -65,14 +65,15 @@ class FileOptionType extends AbstractOptionType { } // determine location the file will be stored at - $package = PackageCache::getInstance()->getPackage($option->packageID); - $fileLocation = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR.$package->packageDir)).$option->filelocation.'.'.$file->getFileExtension(); + $relativeFileLocation = $option->filelocation . '.' . $file->getFileExtension(); + + $fileLocation = PackageCache::getInstance()->getPackage($option->packageID)->getAbsolutePackageDir() . $relativeFileLocation; // save file $file->moveUploadedFile($fileLocation); - // return file location as the value to store in the database - return $fileLocation; + // return relative file location as the value to store in the database + return $relativeFileLocation; } /** -- 2.20.1