Jump to content

PHP Warning: ftp_fget()....


Teck

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/73763-php-warning-ftp_fget/
Share on other sites

<?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

Link to comment
https://forums.phpfreaks.com/topic/73763-php-warning-ftp_fget/#findComment-372169
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.