Current location: Hot Scripts Forums » Programming Languages » PHP » Force download then REDIRECT


Force download then REDIRECT

Reply
  #1 (permalink)  
Old 04-30-09, 10:35 PM
phpdoctor's Avatar
phpdoctor phpdoctor is offline
Code Guru
 
Join Date: Feb 2007
Location: New Zealand
Posts: 767
Thanks: 4
Thanked 2 Times in 2 Posts
Question Force download then REDIRECT

Hi guys,
I have the force download part:
PHP Code:

header("Content-type: application/force-download"); 

header('Content-Disposition: inline; filename="' $row['FileName'] . '"'); 
header("Content-Transfer-Encoding: Binary"); 
header("Content-length: ".filesize($path)); 
header('Content-Type: application/octet-stream'); 
header('Content-Disposition: attachment; filename="' $row['FileName'] . '"');
readfile("$path"); 
This part is working... i cant redirect afterwards.

any ideas? iv tryed header location and meta tags

Thanks,
Lex
__________________
01010000 01001000 01010000
Reply With Quote
  #2 (permalink)  
Old 05-01-09, 04:05 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
I don't think this is actually possible?

Also, you're sending the Content-Disposition header twice, and the first time incorrectly. Oh, and the Content-Type header too.


If the page you want the user to redirect to is on your server, then how about you redirect first, and then start the download?
Reply With Quote
  #3 (permalink)  
Old 05-03-09, 04:55 PM
phpdoctor's Avatar
phpdoctor phpdoctor is offline
Code Guru
 
Join Date: Feb 2007
Location: New Zealand
Posts: 767
Thanks: 4
Thanked 2 Times in 2 Posts
Thanks, I knew the code looked abit weird...

What im trying to build is a system where the files are protected and the only way to download them is with download.php. This way I can check if the user is allowed to download it...

What do you mean redirect first, then start the download?

Thanks,
Lex
__________________
01010000 01001000 01010000
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 08:34 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.