View Single Post
Old 12-03-2007, 03:59 PM   #1 (permalink)
bdm
The Acquainted
Good Samaritan 
 
Join Date: Nov 2007
Posts: 127
Thanks: 14
bdm is on a distinguished road
Default 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($chCURLOPT_URL'server');
    
curl_setopt($chCURLOPT_USERPWD"u:p");
    
curl_setopt($chCURLOPT_POSTFIELDS'pdfs=' $_GET['pdfs']);
    
curl_setopt($chCURLOPT_HEADER1); 
    
curl_setopt($chCURLOPT_RETURNTRANSFER1); 
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?
bdm is offline  
Reply With Quote