diff --git a/src/Storage.php b/src/Storage.php index edc43ae..17d8cc0 100644 --- a/src/Storage.php +++ b/src/Storage.php @@ -129,11 +129,11 @@ public function save($file, $preserveFileName = false, $overwrite = false, $conf Yii::$app->security->generateRandomString(), $fileObj->getExtension() ]); - $path = implode(DIRECTORY_SEPARATOR, [$pathPrefix, $dirIndex, $filename]); + $path = implode(DIRECTORY_SEPARATOR, array_filter([$pathPrefix, $dirIndex, $filename])); } while ($this->getFilesystem()->has($path)); } else { $filename = $fileObj->getPathInfo('filename'); - $path = implode(DIRECTORY_SEPARATOR, [$pathPrefix, $dirIndex, $filename]); + $path = implode(DIRECTORY_SEPARATOR, array_filter([$pathPrefix, $dirIndex, $filename])); } $this->beforeSave($fileObj->getPath(), $this->getFilesystem());