cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: How to download a file that has no extension in url? or bypass download prompt?

From: Stephen Pynenburg <spynenburg_at_gmail.com>
Date: Mon, 3 Nov 2008 17:44:01 -0500

There's probably a way to do it in one request, but I think you could just
as easily do this:
<?PHP
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "site/page.php");
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$res = curl_exec($ch);
preg_match("/filename\=(.*)\\n/", $res, $matches);
echo $matches[1]; //the filename
?>

Then do another request with the filename gleaned from that request.

-Stephen

2008/11/3 Jo Anonymous <jojoanon_at_gmail.com>

> Hello,
>
> I am trying to download a csv file which is generated from the url.
>
>
>
> I can login to the website using curl succesfully but I can't download the
> file I want.
>
> The download url looks something like this:
>
> http://www.websitename.com/file.aspx?type=all&download=1
>
>
>
>
> The website has this line in the header:
>
> header("Content-Disposition: attachment; filename=dada.csv");
>
> which brings up a download prompt.
>
>
>
>
> I just want to download the csv file to my server without any prompts.
>
>
>
>
> I've been trying for ages to figure this out, there must be a way.
>
> Many thanks in advance.
>
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>
>

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2008-11-03