0

Simple enough question I hope.

I am using the following type of code to force download:

if ($ext = ppt){                        
header("Content-disposition: attachment; filename= '$filename'");
header('Content-type: application/vnd.ms-powerpoint');
readfile('$file');

However, what I really need, is to force the download AND redirect to a new page.

The previous script is currently ON the page I want to redirect to. I have a link to that page. What I want is so that, as the user goes their it forces the download. However, right now what I get is, that INSTEAD of the user seeing the page it ONLY forces the download.

Thanks!

user187680
  • 663
  • 1
  • 6
  • 20

1 Answers1

2

As you've gathered, launching the download will effectively block you from doing anything further from that script.

Your best option is to make the download script a separate page and just load the new page from your link. Then from the new page, open the download page in a new window/tab (this answer is a good example of how to do it). This is the way most download sites work, like Sourceforge.

Community
  • 1
  • 1
John C
  • 8,223
  • 2
  • 36
  • 47