Hi,
I am trying to read a text file from a password protected FTP server, it seems that the file is found correctly (because if I change the user name, password, or filename I get an error), but I am unable to read its contents. I also tried writing, the file is created with 0 bytes!
Just changing the filename to be a local file (on the same website) or a file that is retrieved remotely through http works fine.
So what am I doing wrong? Please see code below:
<?
$filename = "ftp://username:password@ftp.myserver.com/d:\mypath\myfile.txt";
$file = fopen ($filename, "r");
if (!$file)
{
echo "<p>Unable to open remote file.\n</p>";
exit;
}
$count = 0;
while (!feof ($file))
{
$buffer = fgets($file, 250);
echo $buffer;
$count++;
}
echo "Number of lines = $count";
fclose ($file);
?>