How to force the user to download a file, not to view it?

前端 未结 3 1078
挽巷
挽巷 2020-12-04 03:32

I have a download page where i have kept musics, pictures, ebooks and etc. Whenever users click at the image it opens it, and same things happen with .pdf files if the user

3条回答
  •  萌比男神i
    2020-12-04 04:14

    You have to add a header to force the download.

    header("Content-Disposition: Attachment")
    header("Content-Disposition: Attachment;filename=FILENAME_HERE")
    

    from http://www.symkat.com/force-download-with-http-headers

提交回复
热议问题