Jump to content

how do you forward to a new URL in php??????


jeger003

Recommended Posts

hello,

i have a code that downloads a file....i want it to forward the user to a newurl.com when they click download

 

here is my code

 


header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: " . $mm_type);
header("Content-Length: " .(string)(filesize($path)) );
header('Content-Disposition: attachment; filename="'.basename($path).'"');
header("Content-Transfer-Encoding: binary\n");
readfile($path); // outputs the content of the file
exit();

 

 

i want that code to forward to /index.php

Link to comment
https://forums.phpfreaks.com/topic/213245-how-do-you-forward-to-a-new-url-in-php/
Share on other sites

You should post in the javascript forum.

 

Here's how I would do it though. Do an onclick event that adds like a 2 second timer to redirect the user to another page.

 

Something like:

<a href="download.php" onclick="setTimeout('document.location("http://www.google.com")', 2000); return true">download this!</a>

 

That's not code I've tested (just typed off the top of my head), but should give you the idea.

im still stuck on this one.......i can get it to work with javascript either....does anyone have any other solution? is there another way to hide download location without using header() function in php? because thats what im using and every time i make it forward to another url i get "Header is already sent" error

 

anyone out there?

i want to try it another way......im gonna have the download button forward to the location i want and then download file.....but now when i do that i get the error "header already sent" I dont understand why and where I need to look

 

can anyone help me on this one atleast?

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.