pylons - 在 pylons 中,我如何强制用户下载文件?
问题描述
从 pylon 控制器操作,而不是渲染模板,我想向用户发送文件以供下载。在 PHP 之类的语言中,我可以执行以下操作。我怎样才能在塔中做到这一点?
header("Content-Type: application/octet-stream");
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename=\"file.exe\"");
echo readfile($url);
解决方案
推荐阅读
- javascript - 我可以用 Javascript 永久显示玻利维亚的时间吗?
- sql - Couchbase 查询以获取嵌套级别属性的数据并创建索引
- error-handling - 如何在同一个 RestTemplate 中使用自定义的 ResponseErrorHandler 和 ClientHttpRequestFactory?
- .htaccess - 通过 .htaccess 阻止回程机器
- javascript - 希望按钮在页面加载时隐藏内容,然后在单击按钮时显示
- python - 如何在更新时调用 django save 方法
- python - 如何在将格式错误的 JSON 读入数据帧之前使用 pyspark 修复它
- excel - IF 以特定单元格中的文本值为条件
- php - json 编码的数据没有在 Ajax 上成功检查我的代码
- javascript - 如何检查 CSS 选择器是否在同一个 HTML 标记行上