Reputation: 1009
I was wondering if there was any way in PHP to pass an external download off to a user? What I would like to do with the script is depending on certain conditions, send the user a file from server A or server B. However, I don't want the user to know the direct url to either server.
Ex: User visits (which is on server C): http://example.com/download?id=1234 Server A's Address to file: http://servera.com/1234.exe Server B's Address to file: http://serverb.com/1234.exe
Is there a way, that when someone visits http://example.com/download?id=1234, to send them the download of the other servers without giving the user the direct URL? I know I can do a file([external file here]). But I do not want all the bandwidth going through server C. Server C is pretty much just a redirect.
Thanks, James
Upvotes: 0
Views: 553
Reputation: 4009
hum
You may be able by using NAT or a Proxy. But this will be very difficult.
Only by modifying the headers it probably won't work.
EDIT: No, I think, you would have to add a proxy for all your servers at once (e.g. gateway).
Upvotes: 0
Reputation: 49395
The client must know at some level which server they are downloading from, otherwise they wouldn't be able to connect to it.
EDIT:
If you don't want the address bar of the browser to change, you can try using the Content-disposition
header like so:
header("Content-disposition: attachment;filename=1234.exe");
//then output the file contents
Note: this PHP script has to be on server A and server B. So server C will redirect to either http://servera.com/download.php or http://serverb.com/download.php.
Upvotes: 2