Download a remote file to a server

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dmcewan
Forum Newbie
Posts: 3
Joined: Thu Feb 09, 2006 3:58 pm

Download a remote file to a server

Post by dmcewan »

I have medium level of PHP skill, and I was wondering if anybody has any opinions of the best way to just download a remote file to a php server. If for example someone passed a URL of "http://localhost/dl.php?www.anywhere.co ... oc.torrent" what would be the best way (in PHP) for the server to save that torrent file from the remote location to a local directory on the server.

Thanks in the advance for even reading this post!

== David
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

e.g.

Code: Select all

$s = fopen($url, 'rb');
file_put_contents('localfile.name', $s);
themasterofthedisaster
Forum Commoner
Posts: 31
Joined: Mon Jul 09, 2007 6:23 am

Post by themasterofthedisaster »

Bittorrent in PHP. Greate idea! But is it possible to build such a PHP program???
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

themasterofthedisaster wrote:Bittorrent in PHP. Greate idea! But is it possible to build such a PHP program???
There are a couple php clients out there, dig around.
dmcewan
Forum Newbie
Posts: 3
Joined: Thu Feb 09, 2006 3:58 pm

Thanks

Post by dmcewan »

I'm actually just trying to create a little script that will kick off a download on a windows machine. I'll post the code once I get it up.
themasterofthedisaster
Forum Commoner
Posts: 31
Joined: Mon Jul 09, 2007 6:23 am

Post by themasterofthedisaster »

Lol, PHP P2P, sounds gretate. Here I have found some info: http://www.vclcomponents.com/PHP/File_M ... -info.html
Ill continue searching...
Post Reply