diff --git a/src/BunnyAPIStorage.php b/src/BunnyAPIStorage.php index 87d8ec7..4808193 100644 --- a/src/BunnyAPIStorage.php +++ b/src/BunnyAPIStorage.php @@ -79,10 +79,13 @@ public function folderExists(string $path): bool public function createFolder(string $name): array { - if (ftp_mkdir($this->connection, $name)) { - return array('response' => 'success', 'action' => __FUNCTION__, 'value' => $name); + if (@!ftp_chdir($this->connection, $name)) { + if (ftp_mkdir($this->connection, $name)) { + return array('response' => 'success', 'action' => __FUNCTION__, 'value' => $name); + } + return array('response' => 'fail', 'action' => __FUNCTION__, 'value' => $name, 'message' => "Failed to create directory $name"); } - return array('response' => 'fail', 'action' => __FUNCTION__, 'value' => $name); + return array('response' => 'fail', 'action' => __FUNCTION__, 'value' => $name, 'message' => "Directory $name already exists"); } public function deleteFolder(string $name): array