Hi, I hope I am posting in right section.

I am using form_alter hook and add file element like this:

function mymodule_form_alter(&$form, &$form_state, $form_id) 
{
   if ($form_id == 'biblio_node_form')
   {
      $form['digital_library_file'] = array(
         '#type' => 'file',
         '#title' => t('Attach your file'),
         '#description' => t("Upload your bibliography file."),
         '#size' => 40,
         '#weight' => -4,
      );
   
      $form['#submit'][] = 'mymodule_file_create_submit';
}


function mymodule_file_create_submit($form, &$form_state)
{
   ...
}

When in second function I am printing form data, it prints me empty variable 'digital_library_file'.

What did I do wrong?

Comments

nargiza’s picture

I add this to form

$form['#attributes']['enctype'] = 'multipart/form-data';

and now all uploaded files are available in $_FILES array.

Status: Active » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.