dongmao3148
2016-12-28 13:51
浏览 64
已采纳

Symfony:Web目录路径

I have uploaded PDF file in web directory. I get that files as shown below:

$webPath = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/foldername/';

$filename = $webPath . $finddata->getUploadedFileName();
$filename = str_replace("\\", '/', $filename);

It gives me path as below:

D:/xampp/htdocs/projectname/app/../web/uploads/foldername/filename

But I want http path of it.

Can any body help me for this to get http path?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dsqpx86002 2016-12-28 13:54
    已采纳

    Try below

    $isSecure = $request->isSecure() ? 'https://' : 'http://';
    $fileName = $isSecure . $this->getRequest()->getHost() . $this->container->get('templating.helper.assets')->getUrl('uploads/foldername/filename.pdf');
    
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题