Jump to content

Redirect after download


phpcandy

Recommended Posts

Hey, I'm trying to create a success page for users who download files from my site.

I'm streaming out the PDFs and Doc files using readfile and a group of header functions.

 

I want to show a congrats/success page after then download the files. What is the best way out?

I tried header('Location: $url'); after the readfile but it screws up download.

 

I tried JavaScript onclick in a hyperlink and this also screwed up downloads.

 

Can someone help please?

 

Step 1: User clicks on a hyperlink.

Step 2: brwoser will either prompt user to save/open the file or automatically downloads file.

step 3: Either immediately after download completes or user opts to download i want to present them a "thanks" page.

Link to comment
https://forums.phpfreaks.com/topic/121699-redirect-after-download/
Share on other sites

why not say "thanks for downloading" on the download page? since you're sending content from php, you can't use header(), as the headers have already been sent. therefore, you'll have to use something on the browser side, javascript i guess. but then you need to know when the download is finished before you display the thank you. i wouldn't do things this way.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.