public function deleteFile($fname) { $options = array('adapter' => ObjectStorage_Http_Client::SOCKET, 'timeout' => 10); $host = Yii::app()->params['host']; $folder = Yii::app()->params['folder']; $username = Yii::app()->params['username']; $password = Yii::app()->params['password']; try { $fOname = hash('sha512', $fname); $objectStorage = new ObjectStorage($host, $username, $password, $options); $result = $objectStorage->with($folder . '/' . $fOname)->delete(); } catch (Exception $e) { try { @unlink(Yii::app()->basePath . '/attachments/' . $fname); } catch (Exception $e) { } } return true; }