I want to force the browser to download all files linked inside a RSS-Feed, that is created by a php-script.
Therefore I need to change the HTTP-headers of these files and set
header("Content-Disposition: attachment; filename=$file");
(and maybe also some other changes).
At the moment I try to do this using a download script, that sets these parameters.
However, the disadvantage of this method is, that I have to link to “download.php” instead of “target.file”, which is somehow misleading for the user. Besides, I have to reveal the internal file path to the user or use quite a lot of GET-variables instead.
It would be much better if it was possible to change the HTTP-headers inside the script that generates the RSS-Feed. Is there a way to achieve this?
You can’t change the headers from inside the RSS feed. You could, however, hide the
download.phppart with some rewrite magic:This would cause any URL starting with
/download/to be run through your download script:/img/foo.jpg– normal file/download/img/foo.jpg– force a downloadYou could do a similar thing without the PHP too: