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
Comment #1
nargiza commentedI add this to form
$form['#attributes']['enctype'] = 'multipart/form-data';
and now all uploaded files are available in $_FILES array.