I want to populate a row in a database, and upload an image (into a
directory, not the db) from the same form. I'd also like to grab the
$_FILES[filename][name] param to go into the database.

I have NO idea how to do this in Cake - no problem for me otherwise,
but I don't even know where to begin when it comes to doing this
w/Cake. (MVC Kung Fu is weak)

Right now I've got a controller that functions fine to CRUD the data. I
tried out the Files Component by Nicolas Cohen (put it in
app/controllers/components as files.php)

http://cakeforge.org/snippet/detail.php?type=snippet&id=7

added this to the view:

<?php echo $html->file('imageFile') ?>

and this to the controller:

add()
{
yada yada...

if ($this->Business->save($this->params['data']))
                        {
                        if ($_FILES['imageFile'])
                                {
                                    $this->Files->saveAs('imageFile', $imgId, 
WWW_ROOT .
'img'.DS.'uploads'.DS);
                                }

                                //cleanUpFields(effective_to_dt);
                                $this->flash('Your listing has been 
saved.','/businesses');
                        }
else { yada yada }
}

I get this error:

Notice: Undefined index: imageFile in
/myserver/app/controllers/businesses_controller.php on line 219

Is it trying to add imageFile to the db?

FWIW, the upload dir is 777, and the form has the correct enctype.

I've spent WAY too many hours on this one, searching the manual, wiki,
group, lurking on IRC... it's driving me nuts! any help is GREATLY
appreciated. If I can get it working I'll probably write a tutorial to
save a future baker this headache.

Thanks folks


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply via email to