ZF2上传和显示后的图像路径

时间:2014-03-18 15:46:05

标签: zend-framework2

我有这样的虚拟主机配置:

<VirtualHost *:80>
    ServerName mytest.local
    DocumentRoot G:/PHP/mytest/public
    SetEnv APPLICATION_ENV "development"
    <Directory G:/PHP/mytest/public>
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

和UploadForm.php

$file->getFilterChain()->attachByName(
    'filerenameupload',
    array(
        'target'          => './public/uploads/',
        'overwrite'       => true,
        'use_upload_name' => true,
        'randomize' => true,
    )
);

我从我的数据库完成上传后获取图片网址:

./public/uploads/4f3c8338_54f0f253_070305-076_5321f51f96ff1_532866a55f4b6.jpg

当我的vhost配置默认为公用文件夹时,如何在我的视图中显示此图像链接? 试试:

'./public/uploads/4f3c8338_54f0f253_070305-076_5321f51f96ff1_532866a55f4b6.jpg'

$this->basepath() . './public/uploads/4f3c8338_54f0f253_070305-076_5321f51f96ff1_532866a55f4b6.jpg';

但非上述工作。 请帮忙,谢谢!

1 个答案:

答案 0 :(得分:0)

假设通过显示此图片链接&#39;你的意思是用HTML显示图像,它将是:

<img src="/uploads/4f3c8338_54f0f253_070305-076_5321f51f96ff1_532866a55f4b6.jpg">