How to create path to file in web directory in Symfony/Twig ?
Doing this way:
<a href="files/1.jpg">1</a>'
add files/1.jpg
to opened url http://localhost/documents/
, so results in http://localhost/documents/files/1.jpg
Doing this way:
{{ asset('files/1.jpg') }}
generate: /files/1.jpg
I want:
http://localhost/web/files/1.jpg
Have a look there https://symfony.com/doc/current/templating.html#linking-to-assets
Maybe this is what you're looking for:
<img src="{{ absolute_url(asset('images/logo.png')) }}" alt="Symfony!" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.