Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Symfony:Web目录路径_Php_Symfony - Fatal编程技术网

Php Symfony:Web目录路径

Php Symfony:Web目录路径,php,symfony,Php,Symfony,我已经上传了网页目录中的PDF文件。我得到的文件如下所示: $webPath = $this->container->getParameter('kernel.root_dir') . '/../web/uploads/foldername/'; $filename = $webPath . $finddata->getUploadedFileName(); $filename = str_replace("\\", '/', $filename); 它为我提供了如下路径:

我已经上传了网页目录中的PDF文件。我得到的文件如下所示:

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

$filename = $webPath . $finddata->getUploadedFileName();
$filename = str_replace("\\", '/', $filename);
它为我提供了如下路径:

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

但是我想要它的http路径

有人能帮我获取http路径吗?

试试下面的方法

$isSecure = $request->isSecure() ? 'https://' : 'http://';
$fileName = $isSecure . $this->getRequest()->getHost() . $this->container->get('templating.helper.assets')->getUrl('uploads/foldername/filename.pdf');
试试下面

$isSecure = $request->isSecure() ? 'https://' : 'http://';
$fileName = $isSecure . $this->getRequest()->getHost() . $this->container->get('templating.helper.assets')->getUrl('uploads/foldername/filename.pdf');