simple ftp fopen() not working??
Posted: Wed Jan 04, 2012 8:27 am
Let me apologize in advance for asking this simple of a question, but I am pulling my hair out and it's not working.
Trying to copy 14 gif files located on #1 server and write to #2 server for to use later.... this is as far as I've made it.
Local File--> C:\Documents and Settings\Ron.PC192371242527\Desktop\jsnh-000.gif
Server File--> jsnh-000.gif
connected--> Resource id #2
logged on result 1
( ! ) Warning: fopen(jsnh-000.gif) [function.fopen]: failed to open stream: No such file or directory in C:\wamp\www\GetFtpFileWriteToFtp.php on line 18
Trying to copy 14 gif files located on #1 server and write to #2 server for to use later.... this is as far as I've made it.
Local File--> C:\Documents and Settings\Ron.PC192371242527\Desktop\jsnh-000.gif
Server File--> jsnh-000.gif
connected--> Resource id #2
logged on result 1
( ! ) Warning: fopen(jsnh-000.gif) [function.fopen]: failed to open stream: No such file or directory in C:\wamp\www\GetFtpFileWriteToFtp.php on line 18
Code: Select all
// define some variables
$ftp_server = "ftp.server.com";
$server_file = "jsnh-000.gif";
$local_file = "C:\Documents and Settings\Ron.PC192371242527\Desktop\jsnh-000.gif";
echo "Local File--> $local_file --Server File--> $server_file<br>\n";
// set up basic connection
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect");
echo "connected--> $conn_id<br>\n";
// login with username and password
$login_result = ftp_login($conn_id, "xxxx","xxxx") or die("Couldn't login");
echo "logged on result $login_result<br>\n";
// try to download $server_file and save to $local_file
if (fopen($server_file, 'r')) {
echo "Successfully opened $server_file<br>\n";
fclose($server_file);
echo "sucessfully closed $server_file";
} else {
echo "There was a problem<br>\n";
}
// close the connection
ftp_close($conn_id);