+ Reply to Thread
Results 1 to 3 of 3

Thread: FTP errors from PHP

  1. #1
    elohim is offline x10Hosting Member elohim is an unknown quantity at this point
    Join Date
    Sep 2007
    Posts
    13

    FTP errors from PHP

    I am trying to use FTP from my PHP program to read a directory.

    ftp_nlist returns Bool(False)

    Some PHP sites suggest to set ftp_pasv to TRUE after the login, when I do that now I get tihs error:

    Warning: ftp_nlist() [function.ftp-nlist]: php_connect_nonb() failed: Operation now in progress (115) in ....php on line 43

    Thanks

    ---------- Post added at 07:01 PM ---------- Previous post was at 06:01 PM ----------

    Sorry, forgot to include the code sample:

    PHP Code:
     $fconn_id ftp_connect($ftp_host);
     
    $login ftp_login($fconn_id$ftp_user$ftp_password);
     
    ftp_set_option($fconn_idFTP_TIMEOUT_SEC10);
     
    $mode ftp_pasv($fconn_idTRUE);
     if ((!
    $fconn_id) || (!$login) || (!$mode)) {
      die(
    "FTP connection failed.");
     }
     
    $mode ftp_pasv($fconn_idTRUE);
     
    $file_list ftp_nlist($fconn_id".");
     
    var_dump($file_list);
     
    ftp_close($fconn_id); 
    This gives me a timeout (after 10 seconds):
    Warning: ftp_nlist() [function.ftp-nlist]: php_connect_nonb() failed: Operation now in progress (115) in /home/elohim/public_html/pkStats/load_xml.php on line 42
    bool(false)

    If I comment out the ftp_pasv lines, then I get (immediately):
    bool(false)

    Any ideas?
    Thanks

  2. #2
    leafypiggy's Avatar
    leafypiggy is offline Community Advocate leafypiggy is on a distinguished road
    Join Date
    Aug 2007
    Location
    Massachusetts
    Posts
    2,228
    Are you connecting to a local FTP server? If you are, there's much easier ways to achieve this without FTP..

    Also, if you're connecting to a remote server, why not just write a script on the remote server and use CURL to get that script...
    Neil Hanlon | x10Hosting Support Representative
    Neil[at]x10hosting.com
    █ I'm always happy to help. Just ask a question in Free Hosting
    Terms of Service IRC

  3. #3
    bdistler's Avatar
    bdistler is offline x10 Lieutenant bdistler is an unknown quantity at this point
    Join Date
    May 2010
    Location
    Catalina AZ USA
    Posts
    349

    Re: FTP errors from PHP

    For debuging here is a non PHP/FTP I use to list files in a directory
    put it "as is" in a directory then call it from you browser
    or set ==>$dirPath<==

    PHP Code:
    <?php

    // To list the content of a directory you just need to use the combination
    // of opendir() and readdir() functions.
    // directory path can be either absolute or relative
    $dirPath '.';
    $listRHD = array();

    // open the specified directory and check if it's opened successfully
    if ($handle opendir($dirPath))
      {
        print 
    getcwd() . "<br />\n";

        
    // keep reading the directory entries 'til the end
        
    while (false !== ($file readdir($handle)))
          {
            
    // just skip the reference to current and parent directory
            
    if ($file !== "." && $file !== "..")
              {
                if (
    is_dir("$dirPath/$file"))
                  {
                      
    // found a directory, do something with it?
                      
    $listRHD[] = "[" $file "]";
                  }
                  else
                    {
                      
    // found an ordinary file
                      
    $listRHD[] = $file;
                    }
              }
          }

        
    sort($listRHD);

        foreach (
    $listRHD as $key => $val)
          {
            print 
    $val "<br />\n";
          }

       
    // ALWAYS remember to close what you opened
       
    closedir($handle);
      }
      else
        {
          print 
    "ERROR on opendir<br />\n";
        }

    print 
    "-EOF-<br />\n";

    ?>

+ Reply to Thread

Similar Threads

  1. Replies: 3
    Last Post: 08-04-2010, 09:20 AM
  2. Errors???
    By as4s1n in forum Free Hosting
    Replies: 1
    Last Post: 02-18-2010, 01:14 PM
  3. So many errors!!!
    By deathmonkey in forum Free Hosting
    Replies: 0
    Last Post: 02-18-2010, 03:43 AM
  4. MySQL errors and Website Errors.
    By JuniorD in forum Free Hosting
    Replies: 0
    Last Post: 05-28-2008, 03:49 PM
  5. A couple of errors might be user errors!
    By mvpatch in forum Free Hosting
    Replies: 4
    Last Post: 03-18-2008, 01:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers