javascript - How to check whether pdf file exists? -
this question has answer here:
- fastest way check remote file existance 5 answers
i trying check if pdf file exists in arxiv. there 2 example
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
Post a Comment