FTP连接失败

问题描述:

FTP连接失败。请帮帮我。FTP连接失败

$ftpServer = "xxxx.xxx"; //I have put the IP address 
$username = "api"; 
$password = "api123"; 

$connId = @ftp_connect($ftpServer); - not Connecting 

使用FileZilla中与上述凭证传递端口为22的时候不working.But,它的工作在FileZilla中。

但是通过 $ connId = @ftp_connect($ ftpServer,22); - 未连接

我已经在服务器 搭配chmod 777 -R目录名资源文件夹 做这些增加的API用户阿帕奇组 /usr/sbin目录/ usermod命令-a -G阿帕奇API

+5

摆脱'@'的。这抑制了错误信息! – delboy1978uk

+0

只是一个快速提醒,我可以看到你的IP –

+0

可能重复[如何与PHP SFTP?](https://stackoverflow.com/questions/4689540/how-to-sftp-with-php)(SSH与FTP无关,同样的,端口22是用于SSH/SFTP,而不是用于FTP =>您需要使用SFTP而不是FTP。) –

你有没有试过这个脚本?

<?php 
function getFtpConnection($uri) 
{ 
// Split FTP URI into: 
// $match[0] = ftp://username:[email protected]/path1/path2/ 
// $match[1] = ftp:// 
// $match[2] = username 
// $match[3] = password 
// $match[4] = sld.domain.tld 
// $match[5] = /path1/path2/ 
preg_match("/ftp:\/\/(.*?):(.*?)@(.*?)(\/.*)/i", $uri, $match); 

// Set up a connection 
$conn = ftp_connect($match[1] . $match[4] . $match[5]); 

// Login 
if (ftp_login($conn, $match[2], $match[3])) 
{ 
    // Change the dir 
    ftp_chdir($conn, $match[5]); 

    // Return the resource 
    return $conn; 
} 

// Or retun null 
return null; 
} 
?> 

希望这可以帮助你

+1

当第一个立场ftp_connect已经是问题时,这将如何帮助? – rndus2r

+0

'vsftpd'服务在服务器中启动,我希望这发生在服务器维护之后。一旦盯着ftp_connect正在工作。但是什么时候关闭。通过Filezila通过端口22.我能够连接。这怎么可能? – Keerthana