[support] Problem with file upload

Cog Rusty cog.rusty at gmail.com
Sun Apr 27 20:50:41 UTC 2008


On Sun, Apr 27, 2008 at 3:12 AM, Davide Michel 'ZioBudda' Morelli
<michel at ziobudda.net> wrote:
> 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 ???


I am not qualified to say anything about your form, but have you
checked if you can upload your 6 files in a node edit form using
Drupal's standard upload module? If not, then it may be a matter of
PHP settings in php.ini:

upload_max_filesize = 4M
post_max_size = 25M      ; 4x6 files = 24, plus 1 for the rest of the content.
memory_limit = 40M

Other possible reasons for an upload failure include a misconfigured
PHP tmp directory or, on a Windows server, a magic_quotes_gpc=On
setting.


>  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
>
>  --
>  [ Drupal support list | http://lists.drupal.org/ ]
>


More information about the support mailing list