Opening files in browser instead of downloading

后端 未结 4 1038
执念已碎
执念已碎 2020-12-16 14:37

I have a href link to a pdf file that when clicked on it downloads. I want this to just open in a new page instead of downloading.



        
4条回答
  •  生来不讨喜
    2020-12-16 15:19

    Your server should return this http header:

    Content-Type: application/pdf
    

    For viewing in browser it should also return:

    Content-Disposition: inline;filename="myfile.pdf"
    

    For downloading:

    Content-Disposition: attachment;filename="myfile.pdf"
    

提交回复
热议问题