diff --git a/h5p-default-storage.class.php b/h5p-default-storage.class.php index fb58f30..aa9c80a 100644 --- a/h5p-default-storage.class.php +++ b/h5p-default-storage.class.php @@ -265,9 +265,13 @@ class H5PDefaultStorage implements \H5PFileStorage { * @param int $contentid */ public function saveFile($file, $contentId) { - $path = $this->path . '/' . ($contentId === 0 ? 'editor' : 'content') . '/' . $file->getType() . 's/' . $file->getName(); + // Prepare directory + $path = $this->path . '/' . (empty($contentId) ? 'editor' : 'content/' . $contentId) . '/' . $file->getType() . 's'; self::dirReady($path); + // Add filename to path + $path .= '/' . $file->getName(); + $fileData = $file->getData(); if ($fileData) { file_put_contents($path, $fileData);