I am having trouble figuring out how to attach an uploaded image to a node in my form submit handler. I've been searching for a while now and nothing I've tried has worked. For instance:
$image = $form_state['storage']['image'];
unset($form_state['storage']['image']);
$image->status = FILE_STATUS_PERMANENT;
$file = file_save($image);
$node->field_image['und'][0] = $file;
does not work.
Any help on this would be much appreciated. Thanks.
$node->field_image['und'][0] = (array) $file;
and then you need to callnode_save($node);
after that.var_dump($form_state['values']['image'])
(as well as ['storage']), but that gives me an empty string. And no matter what I do, I don't get an image attached to the node.