[thelist] PHP FTP download Snippet

CDitty mail at redhotsweeps.com
Sat Aug 31 18:30:01 CDT 2002


Hello all,

Hope everyone has an excellent holiday weekend.  I am writing a small php
script that connects via ftp to a site and will download a certain file.  I
have figured out the connection part, but I cannot get the download section
to work like I need.  Can anyone look at my code and see what's
wrong?  Currently, my file is filled with "1"s.

Thanks
Chris

         // Initate the download
         $ret = ftp_get($fp, $filename, $filename, FTP_ASCII);
         while ($ret == FTP_MOREDATA) {

         // Do whatever you want
         echo ".";

                 $fpWrite = fopen("$filename", "w");
                 while(!feof($fpWrite)){
                         $buffer=$ret;
                         fputs($fpWrite,$buffer);
                 }

                 fclose($fpWrite);
         // Continue downloading...
         $ret = ftp_async_continue ($my_connection);
         }
         if ($ret != FTP_FINISHED) {
                  echo "There was an error downloading the file...";
         }




More information about the thelist mailing list