Jump to content

PHP FTP scripting need some help please


kosch

Recommended Posts

Hello

 

I have a site hosted in the rackspace cloudsite and have been trying to write a script to send the nightly backups I take to my own ftp server but it hasnt been going very well. I'm no coder by a mile more server infrastructure so I'm probably missing something obvious here.

 

I was hoping someone could help me figure out what I'm doing wrong.

 

This is what I see when I download the php log.

 

[20-May-2010 06:00:24] PHP Warning:  ftp_put() [<a href='function.ftp-put'>function.ftp-put</a>]: Filename cannot be empty in /mnt/stor3-wc2-dfw1/882921/kosch.xyz.org/web/content/kosch/ftp3.php on line 30

 

I'm not sure why its saying its empty as when I execute the php file $source & $destination_file return the paths I'm looking for.

 

Thanks

 

Kosch

 


// variables
$ftp_server = "ftp.xyz.com";
$ftp_user_name = "user";
$ftp_user_pass = "password";
$destination_file = "/kosch.log";
$sourcefile = "/mnt/stor3-wc2-dfw1/882921/kosch.xyz.org/bk/kosch.log";




// 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 "FTP connection has failed!";
       echo "Attempted to connect to $ftp_server for user $ftp_user_name"; 
       exit; 
   } else {
       echo "Connected to $ftp_server, ddd for user $ftp_user_name";
   echo "<br>";
   echo "$sourcefile,---Source-------------Destination------ $destination_file,<br><br>";
   }

// upload the file
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);  // line 30

// check upload status
if (!$upload) { 
       echo "FTP upload has failed!";
   } else {
       echo "Uploaded $source_file to $ftp_server as $destination_file";
   }

// close the FTP stream 
ftp_close($conn_id);


 

Link to comment
https://forums.phpfreaks.com/topic/202365-php-ftp-scripting-need-some-help-please/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.