Teck Posted October 18, 2007 Share Posted October 18, 2007 I'm using ftp_fget in one of my scripts, when i run it i get this error: [18-Oct-2007 03:06:17] PHP Warning: ftp_fget() [<a href='function.ftp-fget'>function.ftp-fget</a>]: Port ok. in /home/teck/public_html/myscript.php on line 14 [18-Oct-2007 03:07:17] PHP Warning: ftp_fget() [<a href='function.ftp-fget'>function.ftp-fget</a>]: Port ok. in /home/teck/public_html/myscript.php on line 14 Heres my code: <?php $remotefile = "/path/to/the/file/i/want/to/download/my_file.cfg"; $localfile = 'mylocalfile.txt'; $handle = fopen($localfile, 'w'); $connid = ftp_connect($ftpserver); ftp_login($connid, $ftpusername, $ftpuserpass); ftp_fget($connid, $handle, $remotefile, FTP_ASCII, 0) ftp_close($connid); fclose($handle); ?> Any ideas as to why this happens? Quote Link to comment https://forums.phpfreaks.com/topic/73763-php-warning-ftp_fget/ Share on other sites More sharing options...
mattal999 Posted October 18, 2007 Share Posted October 18, 2007 im not quite sure whats heppened there but it looks like the one on http://www.php.net/ftp_fget will work. try copying that code and edit it to your variables Quote Link to comment https://forums.phpfreaks.com/topic/73763-php-warning-ftp_fget/#findComment-372168 Share on other sites More sharing options...
mattal999 Posted October 18, 2007 Share Posted October 18, 2007 <?php // path to remote file $remotefile = '/path/to/the/file/i/want/to/download/my_file.cfg'; $localfile = 'mylocalfile.txt'; // open some file to write to $handle = fopen($localfile, 'w'); // set up basic connection $connid = ftp_connect($ftpserver); // login with username and password $loginresult = ftp_login($connid, $ftpusername, $ftpuserpass); // try to download $remotefile and save it to $handle if (ftp_fget($connid, $handle, $remotefile, FTP_ASCII, 0)) { echo "successfully written to $localfile\n"; } else { echo "There was a problem while downloading $remotefile to $localfile\n"; } // close the connection and the file handler ftp_close($connid); fclose($handle); ?> try that Quote Link to comment https://forums.phpfreaks.com/topic/73763-php-warning-ftp_fget/#findComment-372169 Share on other sites More sharing options...
Teck Posted October 18, 2007 Author Share Posted October 18, 2007 No error's it just times out and puts an entry in the error_log file... I just tried it on another server & it works fine so... Hmm Quote Link to comment https://forums.phpfreaks.com/topic/73763-php-warning-ftp_fget/#findComment-372530 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.