新手问题 send_file 下载 PDF 问题

zhurongwell · August 20, 2013 · Last by dianlong1437 replied at August 23, 2013 · 2662 hits

send_file 下载 PDF 时,PDF 文件直接在浏览器里显示,怎么解决才能像下载其他文件一样弹出下载框。

试试加 type 参数

:type => "application/pdf"

你用的 chrome 吧。。

#1 楼 @huacnlee 试了 好像没效果

@zhurongwell 把 disposition 设成 'attachment',或者不要这个参数。

#2 楼 应该是正解。

#6 楼 @metal 关键是我也要有预览功能,只是在下载的时候,给个按钮,不要显示 PDF

#5 楼 @jjzxcc 这样的话后缀名就没了

谢谢 大家 好了 把 disposition 设成 'attachment'就行了

#5 楼 @jjzxcc 非常感谢 是这样的

#8 楼 @zhurongwell Chrome 的 PDF 预览自带下载功能,用户基本上都知道吧?

#12 楼 @nightire 太高估用户智商了

#3 楼 @zhurongwell 用 prawn_rails 的时候,在代码中有个配置使得浏览器可以预览还是强制下载,ff/chrome/ie 上都有效。

prawn_document(:force_download=>true) do |pdf|

应该是有代码差异告诉浏览器用哪种行为,send_file 怎么设置没研究过。

哦,已经好啦,刚看到

16 Floor has deleted
You need to Sign in before reply, if you don't have an account, please Sign up first.