如何创建链接以下载 symfony2 中生成的文档?

2022-01-22 00:00:00 php symfony twig

Documents are created by the system and saved to the folder /web/downloads. I have created a view to display links which will allow a user to download the files, should the user click the links. (standard click to download feature)

I am new to Symfony2 and am getting around the whole routing/controller concept, but how would one create a link to such files while still adhering to the MVC? Does one need to set up routing with a controller or does twig have features which allow it etc.

PS: I have read questions such as How to create a download link in Symfony2? but i do not get if they did something in the routing or just added links etc.

Thank you,

解决方案

Let's make a sample.

Say your project lives in /www/, so /www/web/ is the document root of your symfony2 application. Now everything you try to access that is in /www/web/ over http://server/ will show up.

/www/web/downloads/file.zip would be reachable at http://server/downloads/file.zip by default.

相关文章