Programmatically attaching files
I usually don't throw the (array)$file line because really the only thing the field data needs is the fid, description and display. So I usually do the following:

$node-&gt;field_image[LANGUAGE_NONE][] = array(
  'fid' =&gt; $file-&gt;fid,
  'display' =&gt; 1,
  'description' =&gt; '',
);
node_save( $node );


This way if the display is required, I don't get an error. But that's just me...