I've created a PHP script in order to make backups of web projects. It consists of make a .tar.gz archive, and the send it to a personal FTP Server (with vsftpd).
From many Web server it works fine, but from one particular Web server the script not works correctly.
Here the part of FTP connection:
$connessione = ftp_ssl_connect($ftpServer, $ftpPort, 300);
if($connessione == false)
{
echo("connection failed.\n");
return false;
}
echo("Connection established.\n");
echo("Authenticating for " .$username . " ...\n");
$resLogin = ftp_login($connessione, $username, $password);
if(!$resLogin)
{
echo("authentication failed.\n");
return false;
}
ftp_pasv($connessione, false);
$workingDir = ftp_pwd($connessione);
echo("entering on " . $workingDir . "\n");
echo("Uploading file ... \n");
$fullFilePath = __DIR__ . "/" . $filePath;
$result = ftp_put($connessione, $ftpPath . $file, $fullFilePath, FTP_BINARY);
if($result)
echo("Upload completed.\n");
else
echo("Some error occurred.\n");
ftp_close($connessione);
The error returned by ftp_put
call is:
PHP Warning: ftp_put(): Failed to establish connection.