I have an secure FTP Server with the login details and from PHP, am trying to connect to that secure FTP Server using ftp_ssl_connect/ftp_connect
and ftp_login
function and passing all the parameters properly to the function but I am amazed to see that it does not connect.
If I try to connect to that secure FTP Server from command line using ssh than I am able to do so but when I am trying to connect through php code, it does not connect and so I am not sure why this is happening ?
Also what are the other ways to connect to Secure FTP Server using PHP ?
EDIT : I tried using ssh2_sftp
but still I was not able to connect to secure FTP Server.
EDIT 2 : Are there any other ways to do SFTP with PHP, please advise.
Update : Added code which used ssh2_sftp to connect to secure FTP Server but it didn't worked and program died out with message Cannot connect to Server
<?php
$connection = ssh2_connect('www.server.com', 22);
ssh2_auth_password($connection, 'username', 'password');
$sftp = ssh2_sftp($connection) or die ("Cannot connect to server");
$stream = fopen("ssh2.sftp://$sftp/path/to/file", 'r');
?>