From 60b400a2a3e4b9838d52fb91a427b905932dcb2a Mon Sep 17 00:00:00 2001 From: Devian Date: Fri, 30 Apr 2021 15:18:38 +0800 Subject: Fixed scorm extract path --- src/Manager/ScormManager.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Manager/ScormManager.php b/src/Manager/ScormManager.php index 30d0322..af737d1 100644 --- a/src/Manager/ScormManager.php +++ b/src/Manager/ScormManager.php @@ -172,11 +172,11 @@ class ScormManager $destinationDir = $rootFolder.$hashName; // file path - if (!File::isDirectory($rootFolder.$destinationDir)) { - File::makeDirectory($rootFolder.$destinationDir, 0755, true, true); + if (!File::isDirectory($destinationDir)) { + File::makeDirectory($destinationDir, 0755, true, true); } - $zip->extractTo($rootFolder.$destinationDir); + $zip->extractTo($destinationDir); $zip->close(); } @@ -196,11 +196,17 @@ class ScormManager throw new StorageNotFoundException(); } - $rootFolder = config('filesystems.disks.'.config('scorm.disk').'.root').'/'; - $destinationDir = config('scorm.upload_path').$hashName; // file path + $rootFolder = config('filesystems.disks.'.config('scorm.disk').'.root'); + + if (substr($rootFolder, -1) != '/') { + // If end with xxx/ + $rootFolder = config('filesystems.disks.'.config('scorm.disk').'.root').'/'; + } + + $destinationDir = $rootFolder.$hashName; // file path // Move Scorm archive in the files directory - $finalFile = $file->move($rootFolder.$destinationDir, $hashName.'.zip'); + $finalFile = $file->move($destinationDir, $hashName.'.zip'); return [ 'name' => $hashFileName, // to follow standard file data format -- cgit v1.2.3