From 0ee4cc57fc505dc5a59c47a585c8c5f06ac5ea1f Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Mon, 13 Jun 2016 12:47:44 +0200 Subject: [PATCH] Fixed saveFile not working for default storage --- h5p-default-storage.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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);