wiggst3r Posted June 20, 2008 Share Posted June 20, 2008 Hi I'm trying to dowload a file from my FTP site to my local machine and i keep getting errors. I'm using the following code: $local_file = '/Users/mac/workspace/folder_test/' . $last_file; $server_file = '/folder_name/' . $last_file; // 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_BINARY)) { echo "Successfully written to $local_file\n"; } else { echo "There was a problem\n"; } // close the connection ftp_close($conn_id); The file I'm looking for is in the the folder, 'folder_name' on the ftp server and I'm trying to download it to my workspace on my mac. I get the following errors: Warning: ftp_get(/Users/mac/workspace/folder_test/File.txt) [function.ftp-get]: failed to open stream: No such file or directory in /Users/mac/workspace/folder_test/index.php on line 40 Warning: ftp_get() [function.ftp-get]: Error opening /Users/mac/workspace/folder_test/File.txt in /Users/mac/workspace/folder_test/index.php on line 40 There was a problem Any ideas? Quote Link to comment Share on other sites More sharing options...
ScotDiddle Posted June 20, 2008 Share Posted June 20, 2008 wiggst3r, I ran your code with the following and it worked perfectly. check the leading slashes on your file defs... <?php $local_file = 'images/' . 'ZOS.txt'; // a folder off of document_root $server_file = '/PUDATA/' . 'ZOS.DASD.USAGE.BY.APPLICATION.TXT'; // a folder off of FTP_ROOT $ftpServer = '123.456.789.123'; $ftpUserName = 'Me'; $ftpUserPass = 'MyPW'; // set up basic connection $conn_id = ftp_connect($ftpServer); // login with username and password $login_result = ftp_login($conn_id, $ftpUserName, $ftpUserPass); /* then the rest of your code un changed... */ ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.