Re: http_request
| From: | Justin Patrin | Date: | Wed, 29 Sep 2004 16:25:26 +0000 |
| Subject: | Re: http_request | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-14686@lists.php.net to get a copy of this message | ||
On Wed, 29 Sep 2004 05:28:40 +0000, Mike <barjunk@attglobal.net> wrote:
>
> I would like to use http_request to download a file from a website, to
> the machine that the php script is running on. It is a gzipped file.
>
> Is it right to use http_request? It wasn't clear on the website
> documentation, what I needed to do to make this happen.
>
> Thanks for any direction anyone can provide.
>
require_once('HTTP/Request.php');
$req = new HTTP_Request('http://example.com/file.tgz');
$req->sendRequest();
$fd = fopen('/tmp/file.tgz', 'w');
fwrite($fd, $req->getResponseBody());
fclose($fd);
--
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder
paperCrane --Justin Patrin--