I am trying ot get this to upload a file using an http form. It connects fine, but then I get Ftp upload has failed. I am not sure what I am doing wrong, but I think it is something to do with destination or source file. anyone have any ideas?
<?php
//declare variables
$source_file=$_FILES['userfile']['name'];
$destination_file='/uploads/';
$ftp_server= 'ftp.hawtalta.com';
// set up basic connection
$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, 'username', pass);
// check connection
if ((!$conn_id)) {
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_server";
exit;
} else {
echo "Connected to $ftp_server <br>";
}
// 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 as $destination_file";
}
// close the FTP stream
ftp_close($conn_id);
?>