how to auto download from a http site using php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jonathan184
    New Member
    • Nov 2006
    • 154

    #1

    how to auto download from a http site using php

    Hi I am trying to list the files before trying to do a dowload but the below code will only work on local dirs.

    Does anyone know how i could get the listing of a http site.
    You could take a look at the site to see the files and dir listings I am trying to get.
    speedownload.na i.com - /products/commonupdater/


    Code:
    <?php
    if ($handle = opendir('http://speedownload.nai.com/products/commonupdater')) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {
                echo "$file\n";
            }
        }
        closedir($handle);
    }
    ?>
  • xNephilimx
    Recognized Expert New Member
    • Jun 2007
    • 213

    #2
    you can't access the filesystem of a remote server, you should have a script in the remote server to output the list, and calling it with curl or fopen from your server.

    Comment

    • jonathan184
      New Member
      • Nov 2006
      • 154

      #3
      How about if I do screen scraping of the listing then parse for the filenames and do a wget to download the files. Is there something I could use for screen scraping?

      Comment

      • Niheel
        Recognized Expert Moderator Top Contributor
        • Jul 2005
        • 2433

        #4
        wget, save the file and then parse it
        niheel @ bytes

        Comment

        • xNephilimx
          Recognized Expert New Member
          • Jun 2007
          • 213

          #5
          yep, you can use wget with system or exect php functions

          Comment

          • pbmods
            Recognized Expert Expert
            • Apr 2007
            • 5821

            #6
            Heya, Jonathan.

            If you can log into the remote server using FTP (PHP: FTP - Manual), you could issue an ls command (PHP: ftp_nlist - Manual) and get your listing that way.

            Comment

            Working...