Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP Buffer Error

Status
Not open for further replies.

cmhunt

Programmer
Apr 17, 2001
119
GB
Hi

I'm trying to run a simple FTP script that gets a file from an FTP server and places it locally. The script is
Code:
<?php
// set up basic connection and login with username and password
$ftp_server=&quot;********&quot;;
$ftp_user_name=&quot;****&quot;;
$ftp_user_pass=&quot;****&quot;;
$day=str_pad(date(&quot;z&quot;)+1,3,&quot;0&quot;,STR_PAD_LEFT);
$source_file='*******************';
$destination_file='******************';
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

// check connection
if ((!$conn_id) || (!$login_result)) {
        echo &quot;FTP connection has failed!&quot;;
        echo &quot;Attempted to connect to $ftp_server for user $ftp_user_name&quot;;
        exit;
    } else {
        echo &quot;Connected to $ftp_server, for user $ftp_user_name&quot;;
    }
ftp_close($conn_id);
if (ftp_get($conn_id, $destination_file, $source_file, FTP_ASCII)) {
	        echo &quot;FTP upload has failed!&quot;;
	    } else {
	        echo &quot;Downloaded $source_file From $ftp_server to $destination_file&quot;;
    }
?>

When I run it, I get the error:
Warning: ftp_get(): 1 is not a valid FTP Buffer resource in ****************** on line 21

Then an empty file is transferred to the local destination. Please can someone tell me where I'm going wrong??

Thanks

Chris
 
I'm sorry, that is possibly the most embarrassing post ever!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top