I'm currently trying to write a simple script to download a file, at the moment I am able to connect to the FTP server however I am struggling to download the actual file.
This is the error I am getting:
Warning: ftp_get(): xml.php: No such file or directory in c:\development\Test_Dump\test.php on line 27
FTP download has failed!
<?php
$ftp_server = "server"; // FTP Server
$ftp_user_name = "user"; // Username
$ftp_user_pass = "pass"; // Password
$destination_file = "xml.php";
$source_file = "xml.php"; // File to download
// set up basic connection
$conn_id = ftp_connect($ftp_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";
}
// upload the file
#$download = ftp_get($conn_id, $destination_file, $source_file, FTP_BINARY);
$download = ftp_get($conn_id, $source_file, $destination_file, FTP_BINARY);
// check upload status
if (!$download) {
echo "FTP download has failed!";
} else {
echo "Downloaded $source_file to $ftp_server as $destination_file";
}
// close the FTP stream
ftp_close($conn_id);
?>