File field emptied on node_save I know that similar questions have been asked before but none of the suggestions there have helped me at all.  I've been trying all day to get this node to save file data and nothing has worked.  I'm not sure whether I am missing something, but if anyone could help I appreciate it a whole lot.

This is the code, which seems accurate but when the node save happens the file field is emptied.  So I don't understand what is happening.  I have tried different approaches to this and haven't figured it out yet.

$file_object = file_save_upload('node_file', NULL, $dest, FILE_EXISTS_RENAME);
    if ($file_object !== 0) {
     $node-&gt;field_file_upload[$node-&gt;language][0]['value']=(array)$file_object;

        node_save($node);
    }
Well I answered my own question eventually.  The issue was the format for saving to this particular type of field 'file'.   I changed

$node-&gt;field_file_upload[$node-&gt;language][0]['value']=(array)$file_object;

to

$node-&gt;field_file_upload[0]['fid']=$file_object-&gt;fid;


For some reason the formatting that was given in other answers was not functional for me.  The file field type seems to be very particular about it's format, but it only NEEDS, the fid.  Once the node is loaded the full file array is loaded.

To answer longboardnode what I wanted was the array of data about the file that is stored when the file is uploaded.  Unfortunately node fields seem very picky about formatting.