stevesimo Posted October 24, 2008 Share Posted October 24, 2008 Hi, I have been asked to code an application which for its last job needs to transfer a data textfile using SFTP. I have been given an IP address and a port to connect to but cant get it to work. Before posting here I have had a good luck on the internet and was struggling to find any complete examples. I found the example below but cant get this to work. Here is my code: $ftphost = '123.123.123.123'; $ftpuser = 'username'; $ftppwd = 'password'; $ftpport = 10022; $timelimit = 30; //UTF8 Encode Data $data = utf8_encode($data); // set up ssl connection $ftpconn = ftp_ssl_connect($ftphost, $ftpport, $timelimit) or die("Could not connect to FTP server..."); echo 'Connected to FTP server...<br>'; // login with username and password $login_result = ftp_login($ftpconn, $ftpuser, $ftppwd) or die("Could not login to FTP server...<br>"); echo ftp_pwd($ftpconn); ftp_close($ftpconn); // close the ssl connection This code doesnt even try to tranfer any files, just tries to connect to server and login but I cannot get it to work. Can anyone point me in the right direction. Many thanks Steve Quote Link to comment Share on other sites More sharing options...
stevesimo Posted October 24, 2008 Author Share Posted October 24, 2008 Still made no progress with this problem, can anyone point me in the right direction regarding how to use ftp_ssl_connect for file transfer via PHP. Thanks Steve Quote Link to comment Share on other sites More sharing options...
discomatt Posted October 24, 2008 Share Posted October 24, 2008 From the user docs http://php.net/ftp_ssl_connect Just remember: SSL FTP != SFTP Differences: an SSL FTP connects on port 990, and you need an ftp server which will support this (seems like none in the SuSE linux distribution do). Even if you get this function to work, and it connects ok to a normal FTP server on port 21, data WILL NOT BE ENCRYPTED. If you don't believe me, go sniff it yourself! Quote Link to comment Share on other sites More sharing options...
discomatt Posted October 24, 2008 Share Posted October 24, 2008 This may help http://pecl.php.net/package/ssh2 Others simply use a console-based app with exec. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.