Hello,
I have a few scripts now reading files from an FTP, etc. My last step was to move the file from the FTP site, into a directory on the WebServer.
$ftp_server = "IP";
$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);
$local_file = "abc.txt";
$server_file = "abc.txt";
ftp_pasv($conn_id, true);
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";
}
ftp_close($conn_id);
My output is:
Warning: ftp_get(abc.txt) [function.ftp-get]: failed to open stream: Permission denied in /home/guest/www_root/ftp_get.php on line 6
Warning: ftp_get() [function.ftp-get]: Error opening bbpt.txt in /home/guest/www_root/ftp_get.php on line 6
There was a problem
I've tried a variety of local_file and server_file with the full file path as well. I moved the abc file to the root directory of the username/password on the ftp site instead of in the real path where I want it.
Not quite sure where I'm going wrong... Any ideas where my file permission error is? Thanks!
EDIT: I should point out I really have an include file in there for the connection, so line 6 is really the ftp_get() line.