-1

Possible Duplicate:
How to force download of a file?
Forced downloading large file with php

I have a website which lists a whole load of downloads, the links are generated dynamically from a database but I've run into a problem trying to post a .mov file.

I basically need to force this to download instead of viewing in the browser.

I found a couple of thread suggestion Content-Disposition but it didn't look to work with dynamically created links.

Is there any simple way to achieve this?

Community
  • 1
  • 1
0Neji
  • 1,038
  • 1
  • 14
  • 36
  • Content-Disposition is the only way to influence on browser's behaviour, if you simply post the link to static file you won't solve the issue, you need to pass it via some server-side language. Alternatively you can look into apache settings for certain type sof files. – Serg Nov 02 '12 at 13:36
  • Thanks for the links - but they use headers. I was under the impression that I couldn't use headers after html output? – 0Neji Nov 02 '12 at 13:38
  • @0Neji Why are you outputting HTML before a .mov? – deceze Nov 02 '12 at 13:41
  • I'm outputting after because this is a download link generated dynamically. I want users to click the link but have the file download - not view in the browser. – 0Neji Nov 02 '12 at 13:43
  • The code is simply a link tag. – 0Neji Nov 02 '12 at 13:44
  • This is NOT a duplicate question. As I have stated above, those solutions use headers. I don't think I can use that here as my link is generated dynamically within the HTML. – 0Neji Nov 02 '12 at 13:59
  • You misunderstand "after HTML". Downloading a file is an entirely separate HTTP request where new headers are issued. It has nothing to do with any HTML page which came in a different request before. **The solution is headers**, there is no other way. Try to learn more about HTTP. – deceze Nov 02 '12 at 15:17

1 Answers1

0

It has to work unless you did something wrong.

Check out this link: http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html

P.S It would be good to see some code on what you tried.

transilvlad
  • 13,974
  • 13
  • 45
  • 80
  • The browser settings will decide if the MOV file is displayed in the browser, displayed with an external program, or just saved to disk. – Jocelyn Nov 02 '12 at 13:35
  • 1
    Nop. Browser should obey the disposition. This is an RFC standard and as such all Browsers need to obey it. I have had dealings with this multiple times and it never fails on any of the major browsers. Browsers can decide what to only if a disposition was not provided. – transilvlad Nov 02 '12 at 13:39