Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2004
    Location
    India
    Posts
    3

    Question Unanswered: how to write code to download the file using php

    hi,

    help me how to write a code to download the file from ftp . using PHP, i have tried it using ftp_fget(), but still i am not getting, please send me any example using ftp_fget().

    have a nice day

    from

    sanj

  2. #2
    Join Date
    Feb 2002
    Location
    San Francisco, CA
    Posts
    441
    Hi mate,

    PHP Code:
    <?php

    // open some file for reading
    $file 'somefile.txt';
    $fp fopen($file'w');

    // set up basic connection
    $conn_id ftp_connect($ftp_server);

    // login with username and password
    $login_result ftp_login($conn_id$ftp_user_name$ftp_user_pass);

    // try to download $file
    if (ftp_fget($conn_id$fp$fileFTP_ASCII1)) {
     echo 
    "successfully written to $file\n";
    } else {
     echo 
    "There was a problem with $file\n";
    }

    // close the connection and the file handler
    ftp_close($conn_id);
    fclose($fp);
    ?>
    (lifted from http://www.php.net/ftp_fget)

Posting Permissions

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