private function isWritable($path) { if (!is_dir($path)) { // Path does not exist, check parent return $this->isWritable(dirname($path)); } // Dir exists, check if it's writable return is_writable($path); }