Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Re-direct after Download problem

by Errto (Vicar)
on Aug 21, 2007 at 00:53 UTC ( #633977=note: print w/replies, xml ) Need Help??


in reply to Re-direct after Download problem

What you're trying to do is not directly possible. Your CGI script can send the user a file or redirect them to another URL, but not both.

Also this script is insecure, if for no other reason than that it will allow the user to read any file on the server machine so long as the web server process has access to it. Instead of doing that, have your script form the path to the file as you are doing, then use redirect to send the user to the actual URL of the file so they can download it directly, something like

print $cgiobject->redirect("/$filedir/$filename");
This has the additional benefit of giving the user proper headers for things like Content-type, Last-Modified etc.

Update: made less punchy.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://633977]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2017-06-26 09:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (575 votes). Check out past polls.