[support] Problem with file upload

Davide Michel 'ZioBudda' Morelli michel at ziobudda.net
Sun Apr 27 00:12:13 UTC 2008


Hi all. I need to upload 6 files via a form. In my module I have this 
form's function:

function mymodule_file() {
    return drupal_get_form('mymodule_file_form');
}

/**
 * Implementation of hook_form().
 *
 * Return an array of the form elements needed to edit this node.
 */
function mymodule_file_form() {

  $form = array();
/*$form['replace'] = array(
        '#type' => 'markup',
        '#value' => '<b>'. t('I file vecchi verranno cancellati.') .'</p>',
        '#prefix' => '<div class="description">',
        '#suffix' => '</div>',
        '#weight' => 9
      );
*/
  // Set form parameters so we can accept file uploads.
  $form['#attributes'] = array('enctype' => 'multipart/form-data');
  // standard node title

  // file upload field
  $form['file_obbligazionario'] = array(
    '#type' => 'file',
    '#title' => t('File obbligazionario'),
    '#default_value' => '',
    '#attributes' => array('accept' => 'pdf|doc'),
  );


  $form['file_bond'] = array(
    '#type' => 'file',
    '#title' => t('File bond'),
    '#size' => 40,
  );

  $form['file_80_20'] = array(
    '#type' => 'file',
    '#title' => t('File 80/20'),
    '#size' => 40,
  );

  $form['file_euro'] = array(
    '#type' => 'file',
    '#title' => t('File euro'),
    '#size' => 40,
  );

  $form['file_io'] = array(
    '#type' => 'file',
    '#title' => t('File italian opportunity'),
    '#size' => 40,
  );

  $form['file_monetario'] = array(
    '#type' => 'file',
    '#title' => t('File monetario'),
    '#size' => 40,
    '#default_value' => '',
  );

  $form['submit'] = array(
      '#type' => 'submit',
      '#value' => 'Invia',
      '#weight' => 10,
  );

  return $form;
}

And  the form is correctly render into web browser.
My problem is when I sumbit the form with the files to upload:

function rating_file_form_submit($form_id,&$form_values) {
    dprint_r($form_values);
}

I see this into browser:

Array

(
    [file_obbligazionario] => 
    [file_bond] => 
    [file_80_20] => 
    [file_euro] => 
    [file_io] => 
    [file_monetario] => 
    [op] => Invia
    [submit] => Invia
    [form_token] => d58107a0eb0c91a8952524bbb5b7c239
    [form_id] => rating_file_form
)


Why the files are not uploaded ???

Tnx.

-- 
Michel 'ZioBudda' Morelli                       michel at ziobudda.net
Consulenza sistemistica in ambito OpenSource.
Sviluppo applicazioni web dinamiche (LAMP+Ajax)
Telefono: 0200619074
Telefono Cell: +39-3939890025 --  Fax: +39-0291390660

http://www.ziobudda.net                         ICQ: 58351764  
http://www.ziobuddalabs.it                      Skype: zio_budda
http://www.ajaxblog.it        			MSN: michel at ziobuddalabs.it                   
						JABBER: michel at gmail.com



More information about the support mailing list