【问题标题】:How To Create A Link For "save Image As" To Download an Image In Rails如何为“将图像另存为”创建链接以在 Rails 中下载图像
【发布时间】:2010-04-05 08:40:37
【问题描述】:

我想做一个这样的链接下载

http://idwallpaper.com/download.php?image_id=1517

我已经尝试过类似这样的其他教程

<script>
function SaveFile(fname){
img.document.execCommand('saveas', null ,fname)
}
</script>


<iframe id="img" src="myimage.jpg" width="(image width + 20)px" height="(image height + 25)px" scrolling="no" frameborder="0px"></iframe>



<button onclick="SaveFile('myimage.jpg');">save as</button>

虽然在 FireFox 中不起作用.....

【问题讨论】:

    标签: html ruby-on-rails


    【解决方案1】:
    <a href="myimage.jpg">Save As</a>
    

    加上一个Content-Disposition 标头将其设置为附件。如果你使用 Apache,你可以适应 this PDF example

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-26
      • 1970-01-01
      • 2016-07-16
      • 1970-01-01
      相关资源
      最近更新 更多