Results 1 to 5 of 5

Thread: Warning: ftp_fget()

  1. #1

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    39

    Warning: ftp_fget()

    I made a script to download huge content (.zip) from ftp site. i can see dowloading the content but at the end of downloading. content seems o kb with following errors:

    Warning: ftp_fget() [function.ftp-fget]: Opening BINARY mode data connection for 200701.zip (516269909 bytes). in D:\ VSN_TMS\ftp_downloader.php on line 50


    Could anybody help me out.

    with Regards
    Ramesh

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Warning: ftp_fget()

    post your code up

  3. #3

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    39

    Re: Warning: ftp_fget()

    Here's the code
    ###################################################

    <?php
    //////////////////////////////////////////////////////Following Script Dowloads contents from Phonocat FTP Server Respective folders///////////////////////
    set_time_limit(0);
    // Videoservicesftp server connection variables

    $ftp_server = "@@@@@@";
    $conn_id = ftp_connect($ftp_server) or die("Unable to connect to the server");
    $ftp_user_name = "@@@@";
    $ftp_user_pass = "@@@@@";
    //////////////////////////////////////////////////////////LOGIN WITH USER AND PASSWORD//////////////////////////////////////////////
    // login with username and password
    $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

    ////////////////////////////////CHECHK FTP CONNECTION ////////////////////////////////////////////////////////////////////////

    // check connection
    if ((!$conn_id) || (!$login_result)) {
    echo "FTP connection has failed!";
    echo "Attempted to connect to $ftp_server for user $ftp_user_name";
    exit;
    } else {
    echo "Connected to $ftp_server, for user $ftp_user_name";
    }
    /////////////////////////// GET FTP DIRECTORY /////////////////////////////////////////////////////////////////////////////
    if (ftp_chdir($conn_id, "pub2")) {
    echo "Current directory is now: " . ftp_pwd($conn_id) . "\n";
    } else {
    echo "Couldn't change directory\n";
    }
    echo "<br>";
    $curdir = ftp_pwd($conn_id);


    ////////////////////////////////////////////DOWNLOADING FILES//////////////////////////////////////////////////////////////////////
    $buff = ftp_nlist($conn_id, $curdir);

    for ($i=0;$i<count($buff);$i++){
    downLoadFile($buff[$i]);
    }

    /////////fUNCTION TO DOWNLOAD FILES //////////////////
    function downLoadFile($filename){
    global $conn_id;
    $path=pathinfo($filename);
    $path1="ftp_downloaded/".$path['basename'];
    if(($path['basename']==".") || ($path['basename']==".."))
    return;
    print $path1."<BR>";
    $fh=fopen($path1,"w+");
    echo $downloadfile = ftp_fget($conn_id,$fh,$filename, FTP_BINARY,0);
    fclose($fh);
    if (!$downloadfile) {
    echo "Ftp download has failed!<BR>Retrying the downloading process<BR>";
    downLoadFile($filename);
    }
    else {
    echo "Downloaded Success<BR>";
    }
    }
    //close the connection
    ftp_close($conn_id);

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    ?>
    ####################################################

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Warning: ftp_fget()

    Quote Originally Posted by RameshChaudhary
    I made a script to download huge content (.zip) from ftp site. i can see dowloading the content but at the end of downloading. content seems o kb with following errors:

    Warning: ftp_fget() [function.ftp-fget]: Opening BINARY mode data connection for 200701.zip (516269909 bytes). in D:\ VSN_TMS\ftp_downloader.php on line 50


    Could anybody help me out.

    with Regards
    Ramesh
    Use ftp_pasv() to turn passive more on before making the call to ftp_get():
    PHP Code:
    ftp_pasv($conn_idtrue); 
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  5. #5

    Thread Starter
    Member
    Join Date
    May 2006
    Posts
    39

    Re: Warning: ftp_fget()

    Quote Originally Posted by visualAd
    Use ftp_pasv() to turn passive more on before making the call to ftp_get():
    PHP Code:
    ftp_pasv($conn_idtrue); 
    This does not worked. The problem remains same..
    ramesh

Posting Permissions

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



Click Here to Expand Forum to Full Width