PHP / Zend / SSH-无法接收远程文件

时间:2019-01-21 10:46:55

标签: php ssh zend-framework

我正在尝试连接ssh服务器并下载文件,但出现问题,我不明白为什么。该文件肯定存在,我在互联网上搜索,但没有找到任何可解开此错误的东西。

错误:

  

复印错误:2      ssh2_scp_recv()[function.ssh2-scp-recv]:无法接收远程文件

我的代码:

public function ajaxdownloadfileAction() {

        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender();

        $this->view->lib = $this->_labelsFile;

        $connection = ssh2_connect($this->_configFile->ftp->hostname, $this->_configFile->ftp->port);
        if ($connection) {
            $login = ssh2_auth_password($connection, $this->_configFile->ftp->login, $this->_configFile->ftp->password);
            if ($login) {
                $content = true;
                if ($content) { 
                    $local = ' C:\Users\Public\Downloads ';
                    $fileName = "\\Talend\\PEC_DF6\\FluxSortantAdmissionPEC\\ARCHIVES\\XML\\wzadyyyy.0001054581.ap.xml";   
                    if(!@ssh2_scp_recv($connection,$fileName,$local)){
                        $errors= error_get_last();
                        echo "COPY ERROR: ".$errors['type'];
                        echo "<br />\n".$errors['message'];
                    }
                    else {
                            echo "File copied from remote!";
                        }
                    //$filename = $this->getRequest()->getParam('name'); 
                   // $fileName = "\\Talend\\PEC_DF6\\FluxSortantAdmissionPEC\\ARCHIVES\\XML\\wzadyyyy.0001054581.ap.xml";  
                    //$fileName = $this->_getParam('fileName');  
                    //echo $fileName;die;

                    //ssh2_scp_recv($connection,$filename,$local);

            }
            $connection = null; unset($connection);
        }
     }

    /* $result['status'] = 'OK';
     $result['message'] = 'LE ficheir a bien ete telecharger';

     echo json_encode($result);*/
}

0 个答案:

没有答案