<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Tue, 21 May 2013 21:56:48 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Phil Sturgeon's Blog: Hijacking Headers to Force Downloads]]></title>
      <guid>http://www.phpdeveloper.org/news/17751</guid>
      <link>http://www.phpdeveloper.org/news/17751</link>
      <description><![CDATA[<p>
<i>Phil Sturgeon</i> shows how you can <a href="http://philsturgeon.co.uk/blog/2012/03/hijacking-headers-to-force-downloads">hijack headers</a> in his latest post to force a download to the client (even on a hosted service like <a href="http://pagodabox.com">PagodaBox</a>).
</p>
<blockquote>
The question [I posed on Twitter] was: "How to force a download of any file of any type, not on your server, without Apache tweaking? Images are displaying and need em to download." Essentially, I wanted to be able to link to a file that was not on the server in question and anywhere in the world, which could be of any size, any media type and could be potentially very high traffic.
</blockquote>
<p>
Answers varied from using <a href="http://php.net/readfile">readfile</a> to just letting the browser handle it. None of the responses were quick right until he came across one that recommended some settings in an .htaccess file. It uses <a href="http://httpd.apache.org/docs/current/mod/mod_rewrite.html>mod_rewrite</a> (Apache) to redirect the user to a new resource while adding a "Content-Disposition" header in the process (of "attachment").
</p>]]></description>
      <pubDate>Thu, 29 Mar 2012 11:29:28 -0500</pubDate>
    </item>
  </channel>
</rss>
