Php symfony3中的asset()函数不转换url
我想从数据库动态加载图片 以下是包含图像信息的表格: 控制器代码Php symfony3中的asset()函数不转换url,php,symfony,web,controller,twig,Php,Symfony,Web,Controller,Twig,我想从数据库动态加载图片 以下是包含图像信息的表格: 控制器代码 public function listeproductAction() { $em = $this->getDoctrine()->getManager(); $img = $em->getRepository('AppBundle:image')->findAll(); return $this->render('lucky/images.html.twig', arra
public function listeproductAction()
{
$em = $this->getDoctrine()->getManager();
$img = $em->getRepository('AppBundle:image')->findAll();
return $this->render('lucky/images.html.twig', array(
'img' => $img ,
));
}
{% for im in img %}
<img src="{{ asset('/uploads/brochures/' ~ im.getBrochure()) }} ">
{% endfor %}
<div class="main-content">
<img src="/uploads/brochures/0fa58c757752ced32d04b57bb7fa0d65.png ">
</div>
细枝代码
public function listeproductAction()
{
$em = $this->getDoctrine()->getManager();
$img = $em->getRepository('AppBundle:image')->findAll();
return $this->render('lucky/images.html.twig', array(
'img' => $img ,
));
}
{% for im in img %}
<img src="{{ asset('/uploads/brochures/' ~ im.getBrochure()) }} ">
{% endfor %}
<div class="main-content">
<img src="/uploads/brochures/0fa58c757752ced32d04b57bb7fa0d65.png ">
</div>
{%img%中的im%
{%endfor%}
结果
public function listeproductAction()
{
$em = $this->getDoctrine()->getManager();
$img = $em->getRepository('AppBundle:image')->findAll();
return $this->render('lucky/images.html.twig', array(
'img' => $img ,
));
}
{% for im in img %}
<img src="{{ asset('/uploads/brochures/' ~ im.getBrochure()) }} ">
{% endfor %}
<div class="main-content">
<img src="/uploads/brochures/0fa58c757752ced32d04b57bb7fa0d65.png ">
</div>
问题是
asset
函数找不到图像。图像存储在哪里?web/uploads/brochuresAssuming/web/是您的webroot,您的url是正确的,所以我看不出问题。当我使用{%image%}时,结果中的文件路径将更改,图像的名称也将更改,但当我使用资产时,什么都没有改变?