wget into php

Reply

Join Date: Aug 2006
Posts: 59
Reputation: desiguru is an unknown quantity at this point 
Solved Threads: 1
desiguru desiguru is offline Offline
Junior Poster in Training

wget into php

 
0
  #1
Apr 16th, 2007
Is there anyway I can type wget command into a php and that will download file directly from another server to my own server?
--
Share files up to 1Gb - FileOP.com
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 523
Reputation: pty is on a distinguished road 
Solved Threads: 37
pty's Avatar
pty pty is offline Offline
Posting Pro

Re: wget into php

 
0
  #2
Apr 16th, 2007
Originally Posted by desiguru View Post
Is there anyway I can type wget command into a php and that will download file directly from another server to my own server?
  1. <?php
  2. $foo = system('wget http://www.myserver.com/file.txt ~',$output);
  3. ?>
Note to self... pocket cup
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 1,082
Reputation: digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice digital-ether is just really nice 
Solved Threads: 66
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Veteran Poster

Re: wget into php

 
0
  #3
Apr 16th, 2007
Originally Posted by desiguru View Post
Is there anyway I can type wget command into a php and that will download file directly from another server to my own server?
You can run wget by invoking it via the shell as shown above. This however requires that the configuration on your server allows PHP to execute shell commands.

You can however use the regular PHP functions to achive what you want to do with wget.
These are called the Stream Functions.
http://www.php.net/stream

They range from the simple functions such as:
[HTML]

// retrieve the file into a string
$file = file_get_contents('http://example.com/file.ext');

// retrieve the file into an array containing each line
$linesArray = file('http://example.com/file.ext');

[/HTML]

to a bit lower level functions such as fopen() and fsockopen() that allow a bit more flexibility.

The only restriction on the stream functions is the ability to use the HTTP wrapper for PHP Streams. This is defined in php.ini, called allow_url_fopen.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC