Page 1 of 1

CreateFileUploadInput

Posted: Wed Aug 10, 2005 8:07 pm
by jah
I'm trying to use the CreateFileUploadInput method.
How do I get hold of the $fileUpload, $fileUpload_name, $fileUpload_size and $fileUpload_type variables?

Thanks,

Jon

Re: CreateFileUploadInput

Posted: Wed Aug 10, 2005 9:21 pm
by sjg
That's kind of a pain, actually.

Here's what I did in a module that required uploads. It assumes you've been called via the module interface, and you have the module's $id variable available (as you would in the DoAction method).

Basically, you make sure you create your form as enctype="multipart/form-data"

Then, in your code where you wish to access the file upload, you do something like this:

Code: Select all

if (isset($_FILES[$id.'fieldname']['size']) && $_FILES[$id.'fieldname'] < $somelimit)
{
 do something with $_FILES[$id.'fieldname']['name'] or $_FILES[$id.'fieldname']['type']
}
where 'fieldname' is what you called the field when you created the form.

Good luck!
___Samuel___

Re: CreateFileUploadInput

Posted: Thu Aug 11, 2005 8:05 pm
by jah
Thanks Samuel, this helped me a bit, but I still miss the temporary location of the uploaded file. Do you happen to know that too?

By the way I'm following your advicec in the Skeleton module. It is great reading! Hopefully I'll be able to create my first module.

-----------------------------------------------------------------
Found it: $_FILES[$id.'fieldname']['tmp_name']

Thanks,

Jon