我试图连接我的ssh服务器并下载一个文件,但我遇到了一个问题,我不明白为什么。文件确实存在,我在网上搜索,但没有找到任何东西来解开这个漏洞。
错误:
复制错误:2
ssh2_scp_recv()[函数.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 "
\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);*/
}