简体   繁体   English

Symfony,资产在URL中不包含当前文件夹

[英]Symfony, assets doesn't include current folder in the url

I'm working in a project that had Symfony 3.0.4, in this version we use asset to add the path of web folder to the assets like: 我正在一个具有Symfony 3.0.4的项目中工作,在此版本中,我们使用资产将Web文件夹的路径添加到资产中,例如:

{{ asset('filemanager/fileUploadedByAdmin.jpg') }}

It works perfectly in production and in local servers (Wamp servers) generating urls like: 它在生产环境和本地服务器(Wamp服务器)中生成URL的效果非常理想:

http://localhost/projectName/web/filemanager/fileUploadedByAdmin.jpg

Then the project was updated to the version 3.4.2 and now the same line generates something like: 然后将项目更新到版本3.4.2,现在同一行生成类似以下内容的内容:

http://localhost/filemanager/fileUploadedByAdmin.jpg

And the files aren't found. 并且找不到文件。 There is a way or configuration to get the same result in the 3.4.2 version? 有没有一种方法或配置可以在3.4.2版本中获得相同的结果?

You can use this code: 您可以使用以下代码:

{{ absolute_url(asset('filemanager/fileUploadedByAdmin.jpg')) }}

to generate the absolute URL of an asset using absolute_url function. 使用absolute_url函数生成资产的绝对URL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM