How to Force a file to download using PHP on mobile Browsers?

后端 未结 1 1892
死守一世寂寞
死守一世寂寞 2021-01-14 03:26

I want to write a php script to download some files(extensions - .apk, .dcm, .pdf, .zip etc...) on mobile browsers. I have written a php code to download those files and it

相关标签:
1条回答
  • 2021-01-14 03:52

    Try with the following headers:

    header('Content-Type: application/force-download');
    header('Content-Disposition: attachment; filename="filename"');
    

    The idea is to set the content type to something that the browser doesn't know how to open - that way it will show the save dialogue. You can try it with the actual MIME type, it should work, but I can't test it right now.

    0 讨论(0)
提交回复
热议问题