Connecting Tech Pros Worldwide Help | Site Map

FTP with PHP

  #1  
Old November 21st, 2008, 11:35 PM
CyberCog
Guest
 
Posts: n/a
I want to end up with a script I can run via a cron job to upload
files every night.
So I've been trying to use the samples from the PHP manual in the FTP
functions area.

The file uploads, or at least a file with that name shows up on the
remote server, but it's always empty!?!?

<sigh>

Thanks,

- Cy

Here's my code: <?php


$ftp_server = 'ftp.myserver.com';
$ftp_user_name = 'myUser';
$ftp_user_pass = 'myPass';

// 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, for user $ftp_user_name";
}

$source_file = '/Users/mylocalsite/Sites/myJob/feed/CC27249.txt';
$destination_file = '/tmp/CC27249.txt';

// upload the file //
################################################## ##
//$upload = ftp_put($conn_id, $destination_file, $source_file,
FTP_ASCII);

// check upload status
if (ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY)) {
echo "<p>FTP upload has failed!</p>";
} else {
echo "<p>Uploaded $source_file to $ftp_server as
$destination_file</p>";
}

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

?>
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I enable upload a pdf file with php ? jeddiki answers 2 May 16th, 2009 01:51 PM
Monitor Services on Windows 2003 with PHP xerc answers 3 April 3rd, 2007 03:38 PM
automated upload with PHP Steve Poe answers 9 March 31st, 2007 06:25 PM
Web Stats With PHP? Bob II answers 8 July 17th, 2005 12:37 PM