<div>On further debugging it looks node_save is not working as expected.</div>
<div> </div>
<div>node-save() basicall looks as below</div>
<div> </div>
<div>transaction();</div>
<div> </div>
<div>try</div>
<div>{</div>
<div>//do node save related steps</div>
<div>rollback();</div>
<div>}catch(Exception)</div>
<div> </div>
<div> </div>
<div>Looks during node_save execution, finaly it comes to exception block.</div>
<div><br>Is it a bug or I am doing some mistake before calling node_save().</div>
<div> </div>
<div>Regards</div>
<div>kamal</div>
<div><br> </div>
<div class="gmail_quote">On Wed, Oct 10, 2012 at 7:38 AM, Kamal Palei <span dir="ltr">&lt;<a href="mailto:palei.kamal@gmail.com" target="_blank">palei.kamal@gmail.com</a>&gt;</span> wrote:<br>
<blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PADDING-LEFT:1ex" class="gmail_quote">
<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><span class="HOEnZb"><font color="#888888">
<div>kamal</div>
<div> </div></font></span></blockquote></div><br>