Hi there,
I'm currently playing with the FileHandler snippet by Chris Partridge
(http://cakeforge.org/snippet/detail.php?type=snippet&id=52) and I've
hit a problem!
I can get the file to upload correctly and saved in the correct
location, but I cannot for the life of me get the filename back into
the the data array for storing in the database...
My current code is below:
Model:
uses('file_handler');
class News extends AppModel
{
var $name = 'News';
function beforeSave()
{
$FileHandler =& new FileHandler();
$this->params['data']['image'] = $FileHandler-
>save($_FILES['image']['tmp_name'], $_FILES['image']['name'], 'img/
news/', true);
return true;
}
}
Controller:
function add()
{
if (empty($this->params['data']))
{
$this->render();
}
else
{
if ($this->News->save($this->params['data']))
{
$this->flash('Your News has been saved.','/news');
}
else
{
$this->set('data', $this->params['data']);
$this->render('edit');
}
}
}
It uploads the file aok and adds a db entry, just without any data in
the image field. I'm sure it must be something I'm overlooking, but
I'm stumped!
Any help would be gratefully recieved,
d.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---