1

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

1 Answer 1

1

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!" />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.