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

curl-and-php

Re: request a PDF file

From: Davor _at_ Velcom <_at_>
Date: Wed, 23 Feb 2005 11:27:28 -0500

Freedom wrote:

> Hi, I tried a curl request to get a pdf-document, but I got the
> content in my browser just as text instead of a PDF-format.
> I used the code below:
>
> $ch = curl_init();
> curl_setopt ($ch, CURLOPT_URL, "http://www.domain/wanted.pdf");
> curl_setopt ($ch, CURLOPT_HEADER, 0);

// We'll be outputting a PDF
header('Content-type: application/pdf');

// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="downloaded.pdf"');

 From PHP manual: http://php.net/header

> curl_exec ($ch);
> curl_close ($ch);
>
> But it just seems to work on .html and .pdf files. Who can help me
> with a code that is working on .pdf ?
>
> Thank you for any helpful idea.
>
> Sincerely
>
> Fred
Received on 2005-02-23