Professional Web Applications Themes

ftp problems in 4.2.1 - PHP Development

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; ...

  1. #1

    Default 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$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
    Mathias Koerber Guest

  2. #2

    Default Re: ftp problems in 4.2.1

    Mathias Koerber <mathiaslightspeed.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-Phr immer mekert?


    Niels Braczek Guest

Similar Threads

  1. SQL Problems - can this be right?
    By bmyers in forum Coldfusion Database Access
    Replies: 6
    Last Post: November 16th, 03:31 PM
  2. PDF problems
    By Doug in forum Macromedia Freehand
    Replies: 6
    Last Post: April 21st, 09:41 PM
  3. 2 problems
    By pBarrelas in forum Macromedia Flash Sitedesign
    Replies: 4
    Last Post: December 4th, 09:35 PM
  4. Replies: 0
    Last Post: September 22nd, 02:18 PM
  5. scp problems - again
    By Dr. David Kirkby in forum AIX
    Replies: 7
    Last Post: August 1st, 02:00 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139