Being new to PHP, I thought to use its excellent built-in (take that, ASP!) FTP functions to download info. I snatched code from here and there and wrote the following script. So far I've been able to list the contents of the FTP directory, but the actually downloading has escaped me. I'm hoping someone can help with this:
<?
// set up basic connection
$conn_id = ftp_connect("$ftp_server");
// login with username and password
$login_result = ftp_login($conn_id, "$ftp_user_name", "$ftp_user_pass");
// check connection
if ((!$conn_id) || (!$login_result)) {
echo "No connection available to ";
echo "$ftp_server for user $user";
die;
} else {
echo "Connected to $ftp_server, for user $user. Beginning file download.";
}
//$dir=ftp_pwd($connid);
$list=Array();
$list=ftp_nlist($conn_id, "$dir");
$i=0;
do{
//create file on server to download to
//problem seems to be here
$filename = @fopen("c:\i$", "w");
//never echoes what should be the filename
echo $filename;
//download file
ftp_get ($conn_id, "$filename", "$i", FTP_BINARY);
//print out name of downloaded file
//This line does, in fact, echo the right name
echo $list[$i], "
"; $i++;
}while($list[$i]);
// close the FTP stream
ftp_quit($conn_id);
echo "File download completed.";
?>