当前位置: 动力学知识库 > 问答 > 编程问答 >

html - content disposition not opening save as

问题描述:

Hi I'm trying to make a link open the save as dialog when it is clicked and I have read that you can do it using content disposition.

I have the following link:

<a href="/documents/example-name.pdf">Pdf name has dashes (not sure if this makes a difference)</a>

and I added the following meta tags to the header (of the page with the link in it):

<meta http-equiv="content-disposition" content="attachment" />

<meta name="content-disposition" content="attachment; filename=example-name.pdf" />

But it still opens the pdf rather than opening the save as dialog.

Does anyone know what I'm doing wrong here?

网友答案:

Where did you add these meta tags ? In the page that contains the link ?

If you put these meta tags in the header of that page it won't work because these headers are for the html page not the pdf. If you want to open the dialog you must use a page (php, asp.net,...) that returns the pdf and add the headers in the pdf http response

How can I force a "save as" option when the user clicks a link

分享给朋友:
您可能感兴趣的文章:
随机阅读: