--- media_mover_ftp.module	2009-07-16 16:10:16.000000000 -0500
+++ media_mover_ftpNEW.module	2009-07-16 16:09:58.000000000 -0500
@@ -184,7 +184,7 @@ function media_mover_ftp_config($configu
   $form['mm_ftp_conf']['mm_ftp_dir'] = array(
     '#title' => t('FTP directory'),
     '#type' => 'textfield',
-    '#description' => t('Enter "." for the homedir. No trailing slash.'),
+    '#description' => t('Enter "." for the homedir. No trailing slash. Absolute paths may be more compatible with some ftp servers.'),
     '#default_value' => $configuration['mm_ftp_dir'] ? $configuration['mm_ftp_dir'] : '.',
   );
 
@@ -433,18 +433,31 @@ function media_mover_ftp_get_files(&$con
  * It does this by calling ftp_rawlist twice with a 1 second pause, then checking
  * the results for inconsitancies (uploading file will have increased in size).
  *
- * @param resource $stream
- * @param string $dir
+ * @param resource $connection
+ * @param string $directory
  * @param bool $strict
  *  If strict is TRUE the if any files are still uploading then false is returned
  * @return array 
  */
 function media_mover_ftp_completed_file_list(&$connection, $directory, $strict = FALSE) {
-	$results = array();
+  $results = array();
+
+  // store the present working directory before we change it
+  // and check that $directory is absolute
+  if (($orig_pwd = ftp_pwd($connection)) && (drupal_match_path($directory,'/*'))) {
+    // change working directory to $directory, since some FTP servers only allow you to get list of files under present working directory
+    $chdir = ($directory != $orig_pwd) ? ftp_chdir($connection, $directory) : FALSE;
+  }
+  
   // get 2 listings 1 second appart. If there are no results, exit  
   if (! $pass1 = ftp_rawlist($connection, $directory) ) {
-  	return array(); 
+    if($chdir){
+      // change working directory back to original if changed above
+      ftp_chdir($connection, $orig_pwd);
+    }
+    return array(); 
   }
+  
   // wait for a moment to get the second listing.
   sleep(1);
   $pass2 = ftp_rawlist($connection, $directory);
@@ -457,6 +470,11 @@ function media_mover_ftp_completed_file_
     $results = FALSE;
   }
  
+  // change working directory back to original if changed above
+  if($chdir){
+    ftp_chdir($connection, $orig_pwd);
+  }
+ 
   return $results;
 }
 
