Hello I'm learning Zend Framework and I want to make simple gallery. I have a form and upload photos to db but when I want to display I got strenght text instead of images. How can retrive this images?. In db I have photo row with BLOB type. Here is my code: Controller
public function addAction()
{
$form = new Application_Form_Gallery();
$this->view->form = $form;
if($this->getRequest()->isPost()){
$formData = $this->getRequest()->getPost();
if($form->isValid($formData)){
$image = $form->getValue('file');
$gallery = new Application_Model_Gallery();
$gallery->add($image);
$this->_helper->redirector('index');
}else{
$form->populate($formData);
}
}
}
Model
public function add($photo){
$data = array(
'photo' => $photo,
'created_at' => new Zend_Db_Expr('CURDATE()')
);
$this->insert($data);
}
View:
<div class="img" style="width: 150px; height: 150px;">
<?php foreach($this->gallery as $photo):
echo base64_decode($photo['photo']);
endforeach; ?>
</div>