From: Matthias Schmidt Date: Thu, 7 Sep 2017 16:11:23 +0000 (+0200) Subject: File option type file uses relative path X-Git-Tag: 3.1.0_Alpha_4~18 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9078d83ee83154e32ed9c0668d806409f8d80637;p=GitHub%2FWoltLab%2FWCF.git File option type file uses relative path Close #2404 --- 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; } /**