javascript - How to check whether pdf file exists? -


this question has answer here:

i trying check if pdf file exists in arxiv. there 2 example

arxiv.org/pdf/1207.4102.pdf

arxiv.org/pdf/1207.41021.pdf

the first pdf file , second not , returns error page.

is there way check whether url pdf or not. tried answers in how check if file exists in jquery or javascript? none of them work , return true (i.e. file exists) both urls. there way find url pdf file in javascript/jquery or php?

can solved using pdf.js?

it return correct result.

function gethttpcode($url) {      $ch = curl_init($url);     curl_setopt($ch, curlopt_header, true);        curl_setopt($ch, curlopt_nobody, true);        curl_setopt($ch, curlopt_returntransfer,1);     curl_setopt($ch, curlopt_timeout,10);     curl_setopt($ch, curlopt_useragent, 'mozilla/4.0 (compatible; msie 6.0; windows nt 5.1; sv1)');     $output = curl_exec($ch);     $httpcode = curl_getinfo($ch, curlinfo_http_code);     curl_close($ch);     return $httpcode; 

}

$url = 'http://arxiv.org/pdf/1207.41021.pdf'; if(gethttpcode($url)==200) {  echo  'found'; } else {  echo  'not found'; } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -