I am having an issue with uploading to FTP from my website through PHP.
It connects OK, but then has an issue with the uploading of the image.
HTML
<form action="../scripts/php/saveupload.php" method="post">
<input name="file" type="file" />
<input name="submit" type="submit" value="Upload File" />
</form>
PHP
$ftp_server = "XXXXXX";
$ftp_user_name = "XXXXX";
$ftp_user_pass = "XXXXX";
$destination_file = "/public_html/img/news/";
$source_file = $_FILE['file']['tmp_name'];
// set up basic connection
$conn_id = ftp_connect($ftp_server);
ftp_pasv($conn_id, true);
// 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";
}
// upload the file
$upload = ftp_put($conn_id, $destination_file, $source_file);
// 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);
The message I am getting is:
"Connected to ftp.theucl.co.uk, for user theucl.co.ukFTP upload has failed!"
This is now the error I am getting after following Niths advice on the error...
It appears the error is around the following..
$source_file = $_FILES['file']['tmp_name'];
and
$upload = ftp_put($conn_id, $destination_file.$_FILES['file']['tmp_name'], $source_file,FTP_ASCII);
Obviously there's a common apperance amongst this