12-03-2007, 03:59 PM
|
#1 (permalink)
|
|
The Acquainted
Join Date: Nov 2007
Posts: 127
Thanks: 14
|
Using curl to read a file from an external server?
So I have to read a pdf file as an attachment from an external server. I use for the local server:
PHP Code:
curl_setopt($ch, CURLOPT_URL, 'server'); curl_setopt($ch, CURLOPT_USERPWD, "u:p"); curl_setopt($ch, CURLOPT_POSTFIELDS, 'pdfs=' . $_GET['pdfs']); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
And on the external server with the actual pdf:
PHP Code:
header('Content-Type: application/pdf'); header('Content-Disposition: attachment; filename=test.pdf'); readfile('somepdfgeneratedbytheserver.pdf');
When I use curl_getinfo();, it does return:
Code:
[content_type] => application/pdf
The problem with the code above is that when I echo the results, it spews out all this garbage text.
Any ideas?
|
|
|
|