Index: file.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/file.inc,v
retrieving revision 1.104
diff -u -r1.104 file.inc
--- file.inc	25 Jul 2007 17:41:27 -0000	1.104
+++ file.inc	16 Sep 2007 00:46:30 -0000
@@ -574,8 +574,10 @@
     }
 
     // If we made it this far it's safe to record this file in the database.
-    db_query("INSERT INTO {files} (uid, filename, filepath, filemime, filesize, status, timestamp) VALUES (%d, '%s', '%s', '%s', %d, %d, %d)", $user->uid, $file->filename, $file->filepath, $file->filemime, $file->filesize, FILE_STATUS_TEMPORARY, time());
-    $file->fid = db_last_insert_id('files', 'fid');
+    $file->uid = $user->uid;
+    $file->status = FILE_STATUS_TEMPORARY;, 
+    $file->timestamp = time();
+    drupal_write_record('files', $file);
 
     // Add file to the cache.
     $upload_cache[$source] = $file;
