public function saveAction() { $this->_helper->layout->setLayout('empty_layout'); if ($this->getRequest()->isPost() || $this->getRequest()->isXmlHttpRequest()) { $path = $this->_request->getParam('path'); if (dirname($path) != "/upload/image/head") { $ab_path = $_SERVER['DOCUMENT_ROOT'] . '/' . substr($path, 1); $filename = end(explode('/', $ab_path)); $dest = $_SERVER['DOCUMENT_ROOT'] . '/upload/image/head/' . $filename; if (copy($ab_path, $dest)) { touch($dest, filemtime($ab_path)); $this->delDir($_SERVER['DOCUMENT_ROOT'] . '/upload/temp/' . BLOGGER_NAME . '/'); //将头像插入数据库 $account = new Application_Model_DbTable_Account(); $result = $account->updatePhoto(BLOGGER_ID, '/upload/image/head/' . $filename); if ($result) { $response = '头像设置成功'; } else { $response = "系统忙,请稍后再试!"; } } else { $response = "系统出错,请稍后再试!"; } } else { $response = "头像设置成功"; } $this->_helper->viewRenderer->setNoRender(); $this->_response->appendBody($response); } }