小编Arn*_*d B的帖子

从Controller symfony2返回图像

我想知道如何在没有任何模板的情况下从控制器返回图像.我想将它用于简报中的像素跟踪.

我从这段代码开始

    $image = "1px.png";
    $file =    readfile("/path/to/my/image/1px.png");
    $headers = array(
        'Content-Type'     => 'image/png',
        'Content-Disposition' => 'inline; filename="'.$file.'"');
    return new Response($image, 200, $headers);
Run Code Online (Sandbox Code Playgroud)

但在导航器上我有一个断开的链接(文件未找到...)

controller response symfony

14
推荐指数
3
解决办法
3万
查看次数

标签 统计

controller ×1

response ×1

symfony ×1