Reply to Re: how to write html tag to download a file intead of show content of file in browser

Your name:

Reply:


Posted by David Dorward on 01/15/00 11:39

yihucd@gmail.com wrote:

> I am write a html page that has one link on it. The purpose of the link
> is to popup a window to let the user download/save the Excel file to
> his/her local computer.

<a href="foo.xls">Link Text</a>

> But by using my code, when I click the link "file" in the page, the
> content of the excel file showed in the browser

Then either your server is misconfigured and is claiming that your Excel
file is plain text (or HTML or something else that isn't Excel), or your
browser has the Excel plugin and is configured to use it.

> What I want is that : no matter what the user's default browser is,
> when user click the link in the page, the browser should always pop up
> a window to let the user save the file.

You /can/ use the Content-Disposition header to ask the browser to treat it
as an attachment rather than something to be displayed ... but I don't know
of any browser which doesn't have an option for the user to save the target
of a link instead of opening it with the default handler. If the user has
their browser set up to open Excel files in a plugin, then its likely to be
worth respecting that.

http://www.faqs.org/rfcs/rfc2183.html

> (because it is annoying to show some garbage in the browser window)

Sounds like its a case of the server claiming the Excel file is plain text.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация