你好我正在學習Zend Framework,我想做一個簡單的圖庫。我有一個表格,並上傳照片到數據庫,但是當我想要顯示時,我得到了強化文本,而不是圖像。如何檢索這些圖像?在分貝我有照片行與BLOB類型。這裏是我的代碼:控制器Gallery zend框架
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);
}
}
}
型號
public function add($photo){
$data = array(
'photo' => $photo,
'created_at' => new Zend_Db_Expr('CURDATE()')
);
$this->insert($data);
}
查看:
<div class="img" style="width: 150px; height: 150px;">
<?php foreach($this->gallery as $photo):
echo base64_decode($photo['photo']);
endforeach; ?>
</div>
「強度文本」是什麼意思? – emaillenin
而是像我得到這個「×MøÛ¯yë®=÷÷贖罪óNvÓ¿:ï¯yòxér‰©•E 1 UE「,ZG] <Ó½ù$ñ~v®³M£|」在我的佈局有$ this-> headMeta() - > appendHttpEquiv('Content-Type','image/jpg,image/png;'); –
爲什麼要將圖像存儲到數據庫?爲什麼不將它們上傳到目錄並存儲它們的名稱到數據庫? –