$k = $k + 1;
         $filenames .= "\n" . $contentsArray[$j];
     }
     //$ftpObj->writeLog($handle,"\n".$contentsArray[$j] );
 }
 $totalfiles = "\nTotal number of files at ftp location = " . $k;
 if ($k == 0) {
     $endtime = "\n===============End time of script " . date("l F d, Y, h:i A") . "===================";
     $ftpObj->writeLog($handle, $endtime);
     exit;
 }
 $ftpObj->writeLog($handle, $totalfiles);
 $ftpObj->writeLog($handle, "\nFile names are  ");
 $ftpObj->writeLog($handle, $filenames);
 ## --------------------------------------------------------
 echo "In directory: " . ($cd = $ftpObj->getCurrentDir());
 $fileFrom = '';
 # The location on the one97 server
 $fileTo = '/home/watertracker/webapps/watertracker/media/uploads/audio';
 # Local dir to save to
 $i = 0;
 for ($i = 0; $i < sizeof($contentsArray); $i++) {
     echo "<h4>File: " . $contentsArray[$i] . "</h4>";
     $fileFrom = $cd . "/" . $contentsArray[$i];
     echo "<pre>Downloading from: " . $fileFrom . "</pre>";
     $sfilename = "\n one97 file path: " . $fileFrom;
     $ftpObj->writeLog($handle, $sfilename);
     $fileTo = $fileTo . "/" . $contentsArray[$i];
     echo "<pre>Uploading to: " . $fileTo . "</pre>";
     $dfilename = "\n WebFaction local path: " . $fileTo;
     $ftpObj->writeLog($handle, $dfilename);