Hi,
I managed to get this working from the manual. But it is uploading a local file to the same file name on a remote directory.
How do I code it to upload the local file to a remote directory???
<?php
$host="www.hostname.com";
$user="username";
$password="password";
$conn_id = ftp_connect( $host, 21 );
// set up basic connection
// login with username and password
$login_result = ftp_login($conn_id, $user, $password);
// check connection
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
echo "Attempted to connect to $host for user $user";
exit;
} else {
echo "Connected to $host, for user $user";
}
$source_file = "images/delete.gif";
$destination_file="mainwebsite_html/images/delete.gif"; // I just want to upload to the images directory and not the file itself. when I change it to just the directory it errors out
// upload the file
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
// check upload status
if (!$upload) {
echo "FTP upload has failed!";
} else {
echo "Uploaded $source_file to $host as $destination_file";
}
// close the FTP stream
ftp_close($conn_id);
?>