Hello!
I'm having trouble copying a directory and it's contents from my pc to my server.
I can connect ok but the upload always fails. The permissions on the destination directory are 777 and I have also tried passive mode but that didn't work either.
Many thanks for your help!
$source_file = 'C:\Events\EVENT_' . $event_num;
$destination_file = '/home/cberry/public_html/test1/images/event_images/';
// login with username and password
// turn passive mode on
$login_result = ftp_login($conn_id, $ftp_user, $ftp_pass);
ftp_pasv ($conn_id, true);
// 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 ";
}
// 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 $ftp_server as $destination_file";
}
// close the FTP stream
ftp_close($conn_id);