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.c om';
$ftp_user_name = 'myUser';
$ftp_user_pass = 'myPass';
// set up basic connection
$conn_id = ftp_connect($ft p_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_fi le = '/tmp/CC27249.txt';
// upload the file //
############### ############### ############### #######
//$upload = ftp_put($conn_i d, $destination_fi le, $source_file,
FTP_ASCII);
// check upload status
if (ftp_put($conn_ id, $destination_fi le, $source_file, FTP_BINARY)) {
echo "<p>FTP upload has failed!</p>";
} else {
echo "<p>Uploade d $source_file to $ftp_server as
$destination_fi le</p>";
}
// close the FTP stream
ftp_close($conn _id);
?>
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.c om';
$ftp_user_name = 'myUser';
$ftp_user_pass = 'myPass';
// set up basic connection
$conn_id = ftp_connect($ft p_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_fi le = '/tmp/CC27249.txt';
// upload the file //
############### ############### ############### #######
//$upload = ftp_put($conn_i d, $destination_fi le, $source_file,
FTP_ASCII);
// check upload status
if (ftp_put($conn_ id, $destination_fi le, $source_file, FTP_BINARY)) {
echo "<p>FTP upload has failed!</p>";
} else {
echo "<p>Uploade d $source_file to $ftp_server as
$destination_fi le</p>";
}
// close the FTP stream
ftp_close($conn _id);
?>