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