Forum Moderators: coopster

Message Too Old, No Replies

Php Ftp

         

andrewsmd

1:47 pm on Oct 9, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm new to trying to FTP with php. I found this on the internet but my test just runs for a long time and then errors out. Does anyone know why? I'm pretty sure my FTP is enabled because in my PHP info() it says registered transfer modes and ftp is there. Here is the code of course my login information is different but I'm not posting that.

$ftp_server = "000.000.000.000";
$ftp_user = "userName";
$ftp_pass = "password";

// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");

// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
echo "Connected as $ftp_user@$ftp_server\n";
} else {
echo "Couldn't connect as $ftp_user\n";
}

// close the connection
ftp_close($conn_id);

PHP_Chimp

3:41 pm on Oct 9, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I assume the $ftp_server has been altered so that you were not giving your IP address.

$ftp_server = "000.000.000.000"; // make sure you have a propper ip address in here.
$ftp_user = "userName";
$ftp_pass = "password";
// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
// try to login
if (ftp_login($conn_id, $ftp_user, $ftp_pass)) {
echo "Connected as $ftp_user@$ftp_server\n";
} else {
echo "Couldn't connect as $ftp_user\n";
}
// close the connection
ftp_close($conn_id);

Try the above. The hawk eyed will notice that the @ before ftp_login has been removed. So you may get another error.

When scripts are not working avoid using @ to suppress errors, as no error reporting means that you have not got a clue what is going wrong.

andrewsmd

7:30 pm on Oct 9, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The actual transmission method is sftp I just realized that. Is there something I need to change, or does PHP even support sftp?

grallis

9:01 pm on Oct 9, 2008 (gmt 0)

10+ Year Member



Hey andrewsmd, check this post [webmasterworld.com] out.

eeek

3:40 am on Oct 11, 2008 (gmt 0)