Fix for Fix for Image Field Import

  1. file_copy($path, $dest, FILE_EXISTS_REPLACE);
  2.     $node->field_foto[0]['list'] = 1;
  3.     $node->field_foto[0]['data'] = array('description' => '', 'alt' => '', 'title' => '');
  4.     $node->field_foto[0]['uid'] = 3;
  5.     $node->field_foto[0]['status'] = 1;
  6.     $node->field_foto[0]['timestamp'] = time();
  7.     $node->field_foto[0]['filemime'] = file_get_mimetype($file->filename);
  8.     $node->field_foto[0]['filename'] = basename($path);
  9.     $node->field_foto[0]['filepath'] = $path;
  10.     $node->field_foto[0]['filesize'] = filesize($path);
  11.  
  12.     // Save data to the files table and recieve a new fid.
  13.     drupal_write_record('files', $node->field_foto[0]);

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.