Bulk saving nodes with a file field I'm in the progress of creating a bulk upload function for a Drupal site. Using flash I'm able to upload the files to a specific url that should be able to handle the files.

What I want to do, is not just to upload the files, but create a node of a specific type with the file saved to a file-field that has been setup with CCK. Since these are audio files, it's important that file-field handles the files, so additional meta data can be provided with the getid3 module.

I've taken a look at the code/doc, but wasn't able on the first round to figure out how to handle this. Ideally, there is some function that I've missed, that can handle most of this for me.

If any one has experience with this I would apreciate some pointers on how to approach this matter.
It's pretty straight forward, setup your content type with the required fields, then you want to use code similar to this:

$file = new stdClass();
$file-&gt;filename = basename($filepath);
$file-&gt;filepath = $filepath;
$file-&gt;filemime = $mime;
$file-&gt;filesize = filesize($filepath);

$file-&gt;uid = $uid;
$file-&gt;status = FILE_STATUS_PERMANENT;
$file-&gt;timestamp = time();
drupal_write_record('files', $file);


$node = new StdClass();
$node-&gt;type = 'type';
$node-&gt;body = 'body';
$node-&gt;title = 'title';
$node-&gt;field_file = array(
  array(
    'fid' =&gt; $file-&gt;fid,
    'title' =&gt; basename($file-&gt;filename),
    'filename' =&gt; $file-&gt;filename,
    'filepath' =&gt; $file-&gt;filepath,
    'filesize' =&gt; $file-&gt;filesize,
    'mimetype' =&gt; $mime,
    'data' =&gt; array(
      'description' =&gt; basename($file-&gt;filename),
    ),
    'list' =&gt; 1,
  ),
);
$node-&gt;uid = 1;
$node-&gt;status = 1;
$node-&gt;active = 1;
$node-&gt;promote = 1;
node_save($node);