我想从控制器中的web文件夹中获取pdf文件,但无法弄清楚如何操作。< / p>
我试图获得这样的路径 p>
// 1
$ file = __DIR__。 '/../../../../web/1.pdf';
// 2
$ file = $ this-&gt; get('kernel') - &gt; getRootDir()。'\ .. \ web \ 1.pdf';
// 3 \ n $ isSecure = $ request-&gt; isSecure()? 'https://':'http://';
$ file = $ isSecure。 $ request-&gt; getHost()。 $ this-&gt; container-&gt; get('assets.packages') - &gt; getUrl('1.pdf');
code> pre>
然后使用< a href =“https://symfony.com/blog/new-in-symfony-3-2-file-controller-helper”rel =“nofollow noreferrer”>文件控制器助手但它不起作用 。 p>
如何从公共目录中获取该文件? p>
div>