Index: filefield_sources.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/filefield_sources/filefield_sources.module,v
retrieving revision 1.6
diff -u -r1.6 filefield_sources.module
--- filefield_sources.module	26 Feb 2010 12:39:35 -0000	1.6
+++ filefield_sources.module	13 Mar 2010 01:00:31 -0000
@@ -87,7 +87,7 @@
     'filefield_sources',
   );
   $params = array('save', $widget);
-  $settings += filefield_sources_invoke_all('settings', $params);
+  $settings = array_merge($settings, filefield_sources_invoke_all('settings', $params));
   return $settings;
 }
 
Index: sources/reference.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/filefield_sources/sources/reference.inc,v
retrieving revision 1.3
diff -u -r1.3 reference.inc
--- sources/reference.inc	2 Mar 2010 19:20:13 -0000	1.3
+++ sources/reference.inc	13 Mar 2010 01:00:31 -0000
@@ -66,10 +66,28 @@
 function filefield_source_reference_settings($op, $field) {
   $return = array();
 
-  // Add settings to the FileField widget form.
+  if ($op == 'form') {
+    $return['sources_reference'] = array(
+      '#title' => t('Autocomplete reference options'),
+      '#type' => 'fieldset',
+      '#collapsible' => FALSE,
+    );
+
+    $return['sources_reference']['filefield_source_autocomplete'] = array(
+      '#title' => t('Match file name'),
+      '#options' => array(
+        '0' => t('Starts with string'),
+        '1' => t('Contains string'),
+      ),
+      '#type' => 'radios',
+      '#default_value' => empty($field['filefield_source_autocomplete']) ? '0' : '1', 
+    );
+  }
+  elseif ($op == 'save') {
+    $return[] = 'filefield_source_autocomplete';
+  }
 
   return $return;
-
 }
 
 /**
@@ -187,7 +205,11 @@
   $files = array();
   foreach ($fields as $field) {
     $db_info = content_database_info($field);
-    $result = db_query_range("SELECT f.* FROM {" . $db_info['table'] . "} c INNER JOIN {files} f ON c." . $db_info['columns']['fid']['column'] . " = f.fid WHERE f.filename LIKE '%s%%' AND f.status = 1 ORDER BY f.timestamp DESC", $filename, 0, 30);
+
+    // 1 == contains, 0 == starts with.
+    $like = empty($field['widget']['filefield_source_autocomplete']) ? '%s%%' : '%%%s%%';
+    $result = db_query_range("SELECT f.* FROM {" . $db_info['table'] . "} c INNER JOIN {files} f ON c." . $db_info['columns']['fid']['column'] . " = f.fid WHERE f.filename LIKE '" . $like . "' AND f.status = 1 ORDER BY f.timestamp DESC", $filename, 0, 30);
+
     while ($file = db_fetch_object($result)) {
       $files[$file->fid] = $file;
     }
