Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cgi->redirection

Status
Not open for further replies.

Archon

Programmer
May 1, 2001
17
0
0
US
I'm trying to issue a redirect that forces users to a location to download a file. The location of the file will not change, just in a type thing. Just to get the redirection working first, I tried using:

print $cgi->redirect("http:// .. /temp.txt");

but all this does is print:
Status: 302 Moved Location: http:// .. /temp.txt
on the .html page.

It prints the correct url, but the print statement is all I get. No redirection takes place.

What am I missing?
Thanks
 
More specifically, I'd like to redirect on the click of a button or hypertext, so I could allow time to download the file, then delete it/kill the process.

Any ideas on how to set up the redirect to work onclick?

Thanks again
 
to make sure, are you printing any sort of header with the redirecting script except the redirect one? redirection is controlled in the header of a page, so it needs to be the first thing sent to the browser. also - what web-server/browser combo were you using? that might have something to do with it (IE expects redirect to be used like:[tt]
print $query->redirect(-uri=>' -nph=>1);
[/tt]
(taken from the perldoc entry for CGI))

HTH "If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."
 
This is one of those cases where using a library module is actually more complicated than just doing it yourself. The easiest way to do a redirect is simply:
Code:
print "Location: [URL unfurl="true"]http://www.somewhere.com\n\n";[/URL]
Make sure there are TWO \n at the end. Also, like stillflame said, do not print anything else before you print this.
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top