I need print output of this function to user, but sometimes I get .pdf files and I not need print .pdf
I put a filter in $strURL for not process the URL if end in .pdf but sometimes I need processing URLs that redirect to .pdf files (ex: [login to view URL]) and I can't put CURLOPT_FOLLOWLOCATION to 0
function sGetBuffer( $strURL, $strREFERER )
{
if(substr( $strURL, -4) == '.pdf')) return;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $strURL);
curl_setopt($ch, CURLOPT_REFERER, $strREFERER);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; rv:16.0) Gecko/20100101 Firefox/16.0");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept-Language: en-us,en;q=0.5"));
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
Exists an option for filter format files in php for cURL ?
Thanks in advanced.
I would also check the response after the request to see if the file is a pdf.
First I would check the content type then the actual content of the file.
$25 USD in 1 day
5.0 (11 reviews)
2.6
2.6
2 freelancers are bidding on average $30 USD for this job