How to get the full url for an asset in Controller?

前端 未结 15 2162
悲&欢浪女
悲&欢浪女 2020-12-12 16:13

I need to generate some JSON content in controller and I need to get the full URL to an uploaded image situated here : /web/uploads/myimage.jpg.

How can

15条回答
  •  忘掉有多难
    2020-12-12 17:02

    This one works for me

    $baseurl = $this->getRequest()->getScheme() . '://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBasePath();
    

提交回复
热议问题