Sruj
Sruj

Reputation: 1207

How to create path to file in web directory in Symfony/Twig?

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

Upvotes: 1

Views: 1984

Answers (1)

Gregoire Ducharme
Gregoire Ducharme

Reputation: 1108

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!" />

Upvotes: 1

Related Questions