Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Re-direct after Download problem

by Errto (Vicar)
on Aug 21, 2007 at 00:53 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://633977]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2024-04-26 01:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found