<div>Dear All</div>
<div>I have spent quite a lot of time to attach an existing file at server side to a newly created node.</div>
<div>I googled quite a bit, almost everywhere the examples are there for file uplaod / save and then attach to a node.</div>
<div>Did not get any documentation thats says how to attach an existing file to a newly created node .</div>
<div> </div>
<div>At a high level, my code is as below.</div>
<div> </div>
<div>$node = new stdClass();<br>$node-&gt;type = resume&#39; ;  // a new content type created<br>node_object_prepare($node);<br>$node-&gt;title = My title&#39;;<br>$node-&gt;language = &#39;en&#39;; <br>$node-&gt;uid = 1; <br>
$file_obj = file_load($fid); <br>$node-&gt;field_resume[$node-&gt;language][0] = (array)$file_obj; //field_resume is the machine name for file field<br>node_save($node);</div>
<div><br> </div>
<div>Can somebody please let me know what I am missing here?</div>
<div>The new node is created, with no attachment.</div>
<div>How can I get the file to attached to node.</div>
<div> </div>
<div>Regards</div>
<div>kamal</div>
<div> </div>