2011-08-23 59 views
1

我的照片文件夹存储在Zend Framework应用程序的数据文件夹中。当我尝试从数据文件夹中读取图像文件以显示为用户个人资料照片时,我无法将其显示,并且只有当我禁用了我的视图和布局时才显示它。在zend框架中显示存储在公用文件夹之外的图像

这是我的示例代码:

$appShortPath = $photPlugin->getPathToFileFolders(); 

$databaseFile = '2011/08/18/17c7025cd9f3436e4ad1c02635cc6754.jpg';   

$appPath = $appShortPath . '/data/UploadPhotos/'; 

if(!isset($databaseFile)) 
{ 
    return false; 
} 

$fullPath = $appPath . $databaseFile; 

if(!file_exists($fullPath)) 
{ 
    return false; 
} 

$this->_helper->viewRenderer->setNoRender(true); 
$this->view->layout()->disableLayout(); 

$image = readfile($fullPath); 

header('Content-Type: image/jpeg'); 

$this->getResponse() 
    ->setHeader('Content-Type', 'image/jpeg'); 

$this->view->logo = $image; 

我想要得到的个人资料照片,并在用户个人资料页面显示它

希望有人能帮助 - 感谢

回答

-2

为什么你想将头部设置为类型image/jpeg?

难道你们就不能只设置$this->view->logo = /path/to/jpeg

然后在您的视图脚本

<img src="<?php echo $this->logo; ?>" alt="" /> 
+0

他说,一个非公开的目录,所以他试图读取它并输出数据。 – psynnott

相关问题