CONTROLLER
class ImagesController extends AppController {
var $name = 'Images';
var $uses = array('Image','Person');
var $helpers = array('Html', 'Form');
function add($idp = 0, $mac = 0)
{
if (!empty($this->data) &&
is_uploaded_file($this->data['Image']['File']['tmp_name'])) {
$fileData = fread(fopen($this->data['Image']['File']['tmp_name'], "r"),
$this->data['Image']['File']['size']);
$this->data['Image']['name'] = $this->data['Image']['File']['name'];
$this->data['Image']['type'] = $this->data['Image']['File']['type'];
$this->data['Image']['size'] = $this->data['Image']['File']['size'];
$this->data['Image']['data'] = $fileData;
$this->data['Image']['people_id'] = $idp;
$this->Image->save($this->data);
$this->redirect(array('controller' => 'People', 'action' => 'welcome',$mac));
}
}
When I validate the form, I lose both parameters $idp and $mac.. How can I make them persist?
VIEW
<?php
echo $form->create('Image', array('action' => 'add', 'type' => 'file'));
echo $form->file('File');
echo $form->submit('Upload');
echo $form->end();
?>