[BUGFIX] Correctly treat uploaded file when replacing a file
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Resource / Driver / LocalDriver.php
index 6c389d1..fdf1c48 100644 (file)
@@ -854,7 +854,11 @@ class LocalDriver extends AbstractHierarchicalFilesystemDriver
     public function replaceFile($fileIdentifier, $localFilePath)
     {
         $filePath = $this->getAbsolutePath($fileIdentifier);
-        $result = rename($localFilePath, $filePath);
+        if (is_uploaded_file($localFilePath)) {
+            $result = move_uploaded_file($localFilePath, $filePath);
+        } else {
+            $result = rename($localFilePath, $filePath);
+        }
         GeneralUtility::fixPermissions($filePath);
         if ($result === false) {
             throw new \RuntimeException('Replacing file ' . $fileIdentifier . ' with ' . $localFilePath . ' failed.', 1315314711);