How one can display the file path in node/add page, once it is successfully uploaded, before saving the node.

1 Answer 1


Please try below: file_create_url($file->uri)

function import_form_submit(&$form, &$form_state) {
  // Load the file.
  $file = file_load($form_state['values']['file_fid']);
  // Change status to permanent.
  $file->status = FILE_STATUS_PERMANENT;
  // Save.
  $uploaded = file_save($file);
  if ($uploaded == TRUE) {
    drupal_set_message(t('The file has been uploaded.'));
  else {
    drupal_set_message(t('The file could not be uploaded. Please contact the site administrator.'), 'error');


Also, refer the answer for pre-node save function

  • could you provide more information where to add this code ?
    – Yama
    Commented Jan 7, 2016 at 11:21
  • Please refer the hook_node_presave to do this. hook will be your module name.
    – Kalpan
    Commented Jan 7, 2016 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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