How can I force an Image download in the browser?

前端 未结 2 2151
长情又很酷
长情又很酷 2020-12-01 13:30

I want to force user to download images. Not open in browser.

It is possible to use HTML5 this attribute download but currently only Chrome sup

2条回答
  •  一整个雨季
    2020-12-01 13:51

    There's two ways to do this - one with JS, one with PHP.

    In JS from this site:

    Save this page
    

    In PHP create a script named download.php that is similar to the following code:

    Then set the image link to point to this file like this:

    test
    

提交回复
热议问题