CreateFileUploadInput

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
jah
Forum Members
Forum Members
Posts: 147
Joined: Thu Dec 30, 2004 9:09 am
Location: Norway

CreateFileUploadInput

Post 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
User avatar
sjg
Power Poster
Power Poster
Posts: 310
Joined: Thu Jan 27, 2005 5:11 pm
Location: Los Angeles, CA

Re: CreateFileUploadInput

Post 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___
Many modules available from the http://dev.cmsmadesimple.org
The CMS Made Simple Developer Cookbook is now available from Packt Publishers!
jah
Forum Members
Forum Members
Posts: 147
Joined: Thu Dec 30, 2004 9:09 am
Location: Norway

Re: CreateFileUploadInput

Post 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
Last edited by jah on Thu Aug 11, 2005 8:36 pm, edited 1 time in total.
Post Reply

Return to “Developers Discussion”