Home
Open Source Works

Problem with file upload on wizard module

Hi everybody,
I'm using wizard module in a quite big module I'm writing, and I have to say it's great :)
After a while, I encoutered a problem I can't solve: file uploading.
I see there are problems with multiple files, but I am experiencing problem with just one: during the fourth(and last) step of my wizard, I use a classical drupal 'file' input, but in the _validate and _submit I see nothing.
The only file-related variable I see is in $_REQUEST['files']['wizard'], where I can find the name of the file I submitted, but either $form_values and $_FILES don't contain file references.
Do you have any suggestion?

Thank you in advance

Claudio Beatrice

This is my installed software:
OS: Mac OS X 10.5.2
HTTP Server: Apache/2.0.59 (Unix)
Mysql Server: Distrib 5.0.41, for apple-darwin8.11.1 (i686)
Drupal Version: 5.7
Wizard Version: v 1.8.2.2.2.2 2007/06/21 14:04:43

Drupal API

I think you may be confusing things to do with the Drupal API and file uploads etc. For security reasons, file uploads are handled a little differently than form fields. This is by no means a full example, but something like the following might be of use:

<?php
 
// See if a file was uploaded
 
if($upload = file_save_upload('wizard')) {
   
// Check the size of the file
   
if($upload->filesize > $max_size) {
     
// File is too big - don't use it!
     
drupal_set_message(t('Uploaded file is too large - @sizeK maximum', array('@size' => number_format($max_size / 1024))), 'error');
     
file_delete($upload->filepath);
      return array();
    }

   
// Attempt to load the file...
   
$contents = file_get_contents($upload->filepath, FALSE);
  }
?>

Check the Drupal file_save_upload() API info. It's not overly verbose, but a few web searches on the subject might help fill in the details. For the most part, the Wizard doesn't do anything special for files, and you already seem to know about the various limitations around handling these things. Good luck!