How do I attach a file to a file field when saving (update/insert) a node?
I think that you don't have the fid.

/**
 * Implements hook_node_presave().
 */
function hook_node_presave($node) {

  if($node-&gt;type=='profil'){

    $uri = 'public://profiles/fichier';
    $filename = $node-&gt;title.' - PDF - '.$node-&gt;language.'.pdf';
    $file_path = $uri . '/' . $filename;

    // Output PDF with TCPDF
    $pdf-&gt;Output($file_path, 'F');

    $file_temp = file_get_contents($file_path);

    // Saves a file to the specified destination and creates a database entry.
    $file_temp = file_save_data($file_temp, $file_path, FILE_EXISTS_RENAME);

   $node-&gt;field_fichier = array(
     'und' =&gt; array(
       0 =&gt; array(
        'fid' =&gt; $file_temp-&gt;fid,
        'filename' =&gt; $file_temp-&gt;filename,
        'filemime' =&gt; $file_temp-&gt;filemime,
        'uid' =&gt; $node-&gt;uid;,
        'uri' =&gt; $file_temp-&gt;uri,
        'status' =&gt; 1,
        'display' =&gt; 1
    )
  )
);