Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am returning a stream in some response setting the appropriate content-type header. The behavior I'm looking for is this:

  • If the browser is able to render content of the given content type then it should display it in the browser window.

  • If the browser doesn't know how to render the content, then it should display the "save as" dialog where the filename should be the one provided in the response.

The problem is that if I set the Content-Disposition header with:

"attachment; filename="myfile.txt""

the browser will always display the "save as" dialog.

If I don't set Content-Disposition, the filename used in the "save as" dialog is the one in the URL that doesn't work in my case.

I also tried setting Content-Disposition to inline but the outcome is the same.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
644 views
Welcome To Ask or Share your Answers For Others

1 Answer

The correct way could be:

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...