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

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');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 笔记本上移动热点开关状态查询
  • ¥85 类鸟群Boids——仿真鸟群避障的相关问题
  • ¥15 CFEDEM自带算例错误,如何解决?
  • ¥15 有没有会使用flac3d软件的家人
  • ¥20 360摄像头无法解绑使用,请教解绑当前账号绑定问题,
  • ¥15 docker实践项目
  • ¥15 利用pthon计算薄膜结构的光导纳
  • ¥15 海康hlss视频流怎么播放
  • ¥15 Paddleocr:out of memory error on GPU
  • ¥30 51单片机C语言数码管驱动单片机为AT89C52