如何在 Symfony2 中创建下载链接? [英] How to create a download link in Symfony2?

查看:43
本文介绍了如何在 Symfony2 中创建下载链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的 Symfony2 项目上放置链接,人们可以通过单击链接下载文件.但是,当用户单击链接时,我收到以下错误:

I'm trying to put links on my Symfony2 project where people can download files by clicking a link. However, at the moment when a user clicks on a link I get the following error:

未找到GET/uploads/test/test-audio-live.wmv"的路由

No route found for "GET /uploads/test/test-audio-live.wmv"

如何在不出现此错误的情况下允许下载?

How do I allow downloads without this error appearing?

推荐答案

如果文件确实存在,它甚至不应该被 Symfony 或 PHP 处理.如果您收到此错误,则表示 Symfony 正在查找提供此 url 的路由,因此您的文件实际上并不存在于公共文件夹中.检查您的目录.

If the file actually exists, it should not be even processed by Symfony or PHP. If you get this error it means that Symfony is looking up a route to serve this url, thus your file does not really exist in the public folder. Check your directiories.

这篇关于如何在 Symfony2 中创建下载链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆