PDA

View Full Version : PHP FTP Problems


Doyley
08-18-2005, 12:10 AM
Hi all,

Im having some problems with a ftp connection.

Here is my code

<?php

$conn=ftp_connect("server") or die("COULDNT CONNECT");

if(!ftp_login($conn, "uname", "pass")){

echo "LOGIN FAILED";
die();
}

ftp_pasv($conn, true);

ftp_chdir($conn, 'domains');

ftp_pasv($conn, true);

$list=ftp_raw($conn,'LIST');

$num=count($list);

$x=1;
$y=0;

while($x<=$num){

echo "$list[$y]<br />";

$x=$x+1;
$y=$y+1;
}

ftp_close($conn);

?>

When I run I get

425 Can't open data connection.

This only happens when I use the LISt command in ftp_raw, other command work ok.

Does anyone have any ideas?

Thanks

dur0000
08-18-2005, 01:49 AM
Your connection failure may be due to active/passive connection settings of your network. Using ftp_pasv() function of PHP could solve your problem:
http://www.randomind.com/forum/viewtopic.php?t=7

Doyley
08-18-2005, 04:23 PM
Thanks for your reply..

Im already using the ftp_pasv() function in the code above but that doesnt seem to help.

delinear
08-18-2005, 04:27 PM
Have you tried it with ftp_rawlist() instead? Maybe it needs a directory specifying.