1. function img_exits($url
  2.     $ch = curl_init(); 
  3.     curl_setopt($ch, curlopt_url,$url); 
  4.     curl_setopt($ch, curlopt_nobody, 1); // 不下載 
  5.     curl_setopt($ch, curlopt_failonerror, 1); 
  6.     curl_setopt($ch, curlopt_returntransfer, 1); 
  7.  
  8.     if(curl_exec($ch)!==false) 
  9.         return true; 
  10.     else 
  11.         return false; 
  12.   
  13.  
  14. //方法二,代碼如下: 
  15.  
  16. function img_exists($url)  
  17.     if(file_get_contents($url,0,null,0,1)) 
  18.         return 1; 
  19. else 
  20.         return 0; 
  21.  
  22. // 
  23.  
  24. /** 
  25. @title:如何檢查某個遠(yuǎn)程文件是否存在(php5) 
  26. @author:axgle 
  27. @version:1.0 
  28. *//開源代碼phpfensi.com 
  29. $url='http://www.phpfensi.com/'
  30. echo url_exists($url); 
  31.   
  32. function url_exists($url) { 
  33.   
  34.         $head=@get_headers($url); 
  35.         if(is_array($head)) { 
  36.                 return true; 
  37.         } 
  38.         return false; 
  39.   
  40.  
  41. ?> 
  42.   
  43. 網(wǎng)頁方法,代碼如下: 
  44. <script   language= "javascript">  
  45. function   geturl(url)  
  46. {  
  47.         var   xmlhttp   =   new   activexobject( "microsoft.xmlhttp ");  
  48.         xmlhttp.open( "get ",url,false);  
  49.         xmlhttp.send();  
  50.         if   (xmlhttp.readystate==4)  
  51.             alert((xmlhttp.status==200)? "文件存在 ""文件不存在 ");  
  52. }  
  53. </script>  
  54. 請輸入文件地址: <input   name= "file "   id= "file "   value= "http://www.phpfensi.com ">  
  55. <button   onclick= "geturl(file.value) "> 檢測地址 </button> 
轉(zhuǎn)載請注明來源:php判斷遠(yuǎn)程圖片是否存在

  哈爾濱品用軟件有限公司致力于為哈爾濱的中小企業(yè)制作大氣、美觀的優(yōu)秀網(wǎng)站,并且能夠搭建符合百度排名規(guī)范的網(wǎng)站基底,使您的網(wǎng)站無需額外費(fèi)用,即可穩(wěn)步提升排名至首頁。歡迎體驗(yàn)最佳的哈爾濱網(wǎng)站建設(shè)。