Forum Moderators: coopster
I am trying to download a file from remote site for which i need to post a form which i did using curl and getting the following output
HTTP/1.1 100 Continue
HTTP/1.1 200 OK
Date: Mon, 30 Mar 2009 17:19:59 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Refresh: 890; URL=TimeoutMessage.aspx
Content-disposition: attachment;filename=test.txt
Cache-Control: private
Content-Type: application/octet-stream; charset=utf-8
Content-Length: 30218
// here the content of the test.txt file
Now i want to download the file using curl. Any help would be highly appreciated.
Below is the function which i used for Post the form
function post($url,$data) {
$process = curl_init($url);
curl_setopt($process, CURLOPT_HTTPHEADER, $this->headers);
curl_setopt($process, CURLOPT_HEADER, 1);
curl_setopt($process, CURLOPT_USERAGENT, $this->user_agent);
if ($this->cookies == TRUE) curl_setopt($process, CURLOPT_COOKIEFILE, $this->cookie_file);
if ($this->cookies == TRUE) curl_setopt($process, CURLOPT_COOKIEJAR, $this->cookie_file);
curl_setopt($process, CURLOPT_ENCODING , $this->compression);
curl_setopt($process, CURLOPT_TIMEOUT, 30);
if ($this->proxy) curl_setopt($process, CURLOPT_PROXY, $this->proxy);
curl_setopt($process, CURLOPT_POSTFIELDS, $data);
curl_setopt($process, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($process, CURLOPT_POST, 1);
$return = curl_exec($process);
curl_close($process);
return $return;
}
Thanks
Mahabub
[edited by: Mahabub at 5:58 pm (utc) on Mar. 30, 2009]