【发布时间】:2013-07-01 16:18:08
【问题描述】:
我想知道如何在没有任何模板的情况下从控制器返回图像。 我想用它在时事通讯中进行像素跟踪。
我从这段代码开始
$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);
但是在导航器上我的链接断开了(找不到文件...)
【问题讨论】:
-
刚刚看到消息,但这会有所帮助。 Downloading a file with symfony
标签: symfony controller response