Hi everyone,
I have the following code in a file named importintodb.php. This code appears to be pretty common in books and in the forums. I keep getting the following error:
Warning: ftp_get(): idx/IDXActCm.txt: No such file or directory in "/var/www/vhosts/XXXXXXXX/httpdocs/XXX/importintodb.php"
The error appears to me to be looking for the file within the importintodb.php file rather than going to the FTP server and getting the file.
Does anyone have any thoughts?
Also, is there any advantage to using this over an FTP fopen()?
Thanks in advance!
// define some variables
$local_file = 'IDXActCm.txt';
$server_file = 'idx/IDXActCm.txt';
$ftp_server='IP Address';
$ftp_user_name = 'UN';
$ftp_user_pass = 'PW';
// 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);
// try to download $server_file and save to $local_file
if (ftp_get($conn_id, $local_file, $server_file, FTP_ASCII)) {
echo "Successfully written to $local_file\n";
} else {
echo "There was a problem\n";
}
// close the connection
ftp_close($conn_id);