Fixed saveFile not working for default storage

pull/22/head
Frode Petterson 2016-06-13 12:47:44 +02:00
parent fca0537a4d
commit 0ee4cc57fc
1 changed files with 5 additions and 1 deletions

View File

@ -265,9 +265,13 @@ class H5PDefaultStorage implements \H5PFileStorage {
* @param int $contentid * @param int $contentid
*/ */
public function saveFile($file, $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); self::dirReady($path);
// Add filename to path
$path .= '/' . $file->getName();
$fileData = $file->getData(); $fileData = $file->getData();
if ($fileData) { if ($fileData) {
file_put_contents($path, $fileData); file_put_contents($path, $fileData);