我有我的数据库中的斑点数据,他们是我想要显示为基本画廊的图像。显示斑点图像 - symfony
我有我写了显示图像的方法,但我得到一个错误,说这是一个字符串,而不是返回BLOB数据:
public function getFilenamePath()
{
$file_src = false;
if (null !== $fp = $this->getFilename())
{
$file = stream_get_contents($fp);
$file_src = '/uploads/gallery/'.$this->getId().'.jpg';
}
return $file_src;
}
其中getFilename()
是我的blob列。
行动:
public function executeSingle(sfWebRequest $request)
{
$application_id = $this->getRequestParameter('id');
$c = new Criteria();
$c->addJoin(GalleryPeer::APPLICATION_ID, ApplicationPeer::ID);
$c->addJoin(GalleryImagePeer::GALLERY_ID, GalleryPeer::ID);
$c->add(GalleryPeer::APPLICATION_ID, $application_id);
$this->galleries = GalleryImagePeer::doSelect ($c);
}
模板:
foreach($galleries as $gallery)
{
$path = $gallery->getFilenamePath();
if($path)
{
echo '<img src="'.$path.'" />';
}
}
我得到的错误是stream_get_contents
似乎返回一个字符串。
无论如何,我可以得到blob数据,或者不使用模型方法,使用动作来返回附加到应用程序的所有图像?
感谢
为什么你的图像作为二进制大对象数据存储在数据库中,如果你有他们在本地以及下`/上传/ gallery`?你在哪里使用`$ file`,从你的例子无处? – mhitza 2011-01-10 17:09:38
同意...什么?你为什么要将任何东西流入$文件? – dqhendricks 2011-01-10 17:29:28
看来我使用的代码here正在使用$ file上的stream_get_contents。所以我想我不小心把它丢下了。 – terrid25 2011-01-10 17:40:21