首页 > 解决方案 > 在 pylons 中,我如何强制用户下载文件?

问题描述

从 pylon 控制器操作,而不是渲染模板,我想向用户发送文件以供下载。在 PHP 之类的语言中,我可以执行以下操作。我怎样才能在塔中做到这一点?

header("Content-Type: application/octet-stream");
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename=\"file.exe\""); 
echo readfile($url);

标签: pylons

解决方案


推荐阅读