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) {

  • When you say you want to save file data, are you trying to add the actual file or just its url to the node? According to file_save_upload doc api.drupal.org/api/drupal/includes!file.inc/function/… it already saves the file as a managed file and creates a file id (fid). What do you want field_file_upload to hold? – longboardnode Jun 15 '13 at 4:13

Well I answered my own question eventually. The issue was the format for saving to this particular type of field 'file'. I changed




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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.