ftp problems in 4.2.1

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mathias Koerber

    ftp problems in 4.2.1

    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@$se rver:$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 (!($ftpConnecti on = @ftp_connect($s erver,$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($ftpC onnection);
    return false;
    }
    if (!(@ftp_get($ft pConnection, $dst, $src, $mode))) {
    $this->err_str = _("Could not get file!");
    @ftp_quit($ftpC onnection);
    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@$se rver:$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
  • Niels Braczek

    #2
    Re: ftp problems in 4.2.1

    Mathias Koerber <mathias@lights peed.com.sg> schrieb:[color=blue]
    > 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.[/color]

    [...]
    Your primary problem may be not to know, that 'de' in de.comp.lang.ph p.*
    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?


    Comment

    Working...