Page 1 of 1

Ftp error

Posted: Wed Aug 16, 2006 10:19 am
by ratan
JayBird | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hello, I am trying to download files from a ftp server.  I see the icon of the file in my local directory with 0KB, after which the script
fails and the icon disappears.  I have used windows copy/paste from the FTP site and that works. So, I am not sure what
is the problem here. I am attaching my script. Pls. help.

Code: Select all

$arrFiles = array();
$arrFiles[] = fileNameCreator("file1", "csv");
$arrFiles[] = fileNameCreator("file2", "csv");
$arrFiles[] = fileNameCreator("file3", "csv");

$conn = ftp_connect($HOST,$PORT);
if(!$conn) 
{
	exit("Could not connect to server: $HOST\n");
}

if(!ftp_login($conn,$UN,$PW)) 
{        
	ftp_quit($conn);
   	exit("Could not log in\n");
}
ftp_chdir($conn,$DIR);


foreach($arrFiles as $aF)
{
	$FILE_LOCAL = "C:\tempDir\\".$aF;
	if(!ftp_get($conn,$FILE_LOCAL,$aF,FTP_ASCII)) 
	{
    	echo "Successfully written to $FILE_LOCAL\n";
    } 
    else 
    {
    	echo "There was a problem\n";
    }
}



  ftp_quit($conn);

JayBird | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Wed Aug 16, 2006 12:39 pm
by ratan
It works now..I replaced ftp_get() with file_get_contents()....Thanks!!