By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,824 Members | 1,296 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,824 IT Pros & Developers. It's quick & easy.

ftp problems in 4.2.1

P: n/a
Hi,

I am quite new to PHP (but have experience with perl etc) and am facing
a certain issue with PHP 4.2.1's ftp function.

I am trying to extend a program to fetch a file from a remote server.

I tried:
ob_start();
$retval = @readfile("ftp://$user:$pass@$server:$port/$filename")
if (false != $retval) {
$contents = ob_get_contents()
}
ob_end_clean();

Here the problem is that PHP seems to want to execute a
SIZE /$filename
on the server instead of the correct
SIZE $filename

Using ftp_get I get a different error. Executing this code:
if (!($ftpConnection = @ftp_connect($server,$port))) {
$this->err_str = _("Server connection failed");
return false;
}

if (!(@ftp_login($ftpConnection, $user, $pass))) {
$this->err_str = _("Could not login - check password!");
@ftp_quit($ftpConnection);
return false;
}
if (!(@ftp_get($ftpConnection, $dst, $src, $mode))) {
$this->err_str = _("Could not get file!");
@ftp_quit($ftpConnection);
return false;
}
with a pre-created tempfile (tempnam) as $dst.

the FTP server (proftpd) logs a proper file transfer of n bytes
but the received tempfile is empty and ftp_get returns a FALSE
status.

I cannot however find any further indication of the problem
(such as an error variable or string pinpointing the cause).
I ended up using a
system("wget -O $tempfile ftp://$user:$pass@$server:$port/$filename")
which works a charm but is ugly.

I also find that the ftp_get takes a long time to return. the proftpd
server has long logged a successful transfer and session closure, yet
the function does not return.

does anyone have any hints what could be wrong?

thanks
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Mathias Koerber <ma*****@lightspeed.com.sg> schrieb:
Hi,

I am quite new to PHP (but have experience with perl etc) and am
facing a certain issue with PHP 4.2.1's ftp function.


[...]
Your primary problem may be not to know, that 'de' in de.comp.lang.php.*
stands for 'german'. So repost in the correct language, please, or find
yourself a better fittig newsgroup.

regards
Niels

--
Eigendlich is n Standart in der Rechtschreibung föllig
egal. Hauptsache is, mann ferstet mich! Ich kapier nur
ned, wiso der PHP-Pharser immer mekert?
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.