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
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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.