views:

49

answers:

4

I'm wanting to setup a php script and host it on my server that will let me download files from other locations, but making it look like it's coming from my server. Maybe using curl or htacess. Also I was hoping that there would be a way to get around having my server deal with the bandwidth. Does that make sense? Is this doable?

-- Update

Kind of like a proxy, but without the file downloading to memory and then sending it to the client.

A: 

Also I was hoping that there would be a way to get around having my server deal with the bandwidth. Is this doable?

No.

Cheeso
+1  A: 

You can do this by simply passing the target url to you script, open the url with file_get_contents(), curl or other file functions and echo the data. ensure to set the Content-Type header to "application/octet-stream" to force the browser to save the file instead of displaying it.

As for the bandwidth: You'll have to deal with it. If your server downloads a file, it will use up the bandwidth. It will even use it up twice because it has to receive AND send the data.

I don't know why you mention htaccess, because that has nothing to do with your problem.

Techpriester
The reason why I mentioned htaccess, cause I was wondering if there might be a way to use maybe mod_rewrite to make it "look" like the file is on my server but really it's just connecting to another location.
will
A: 

I'd recommend setting up a linking system on your site like http://example.com/download.php?id=12 that would then forward directly to the remote file, that way you'd save on bandwidth and if someone look at the link on your page it would look like it coming from your server. It would still show the other site in the download manager but if your trying to save bandwidth it's a small price to pay.

Scott
A: 

Thanks for the help... I figured out what I was needing to do, I'm going to use mod_xsendfile. It lets you set an external source for where the file is located, and then lets the user download the file without knowing where the file actually is located.

will