php判断远程图片是否存在
发布时间:2022-06-18 15:33:21 所属栏目:PHP教程 来源:互联网
导读:function img_exits($url) { $ch = curl_init(); curl_setopt($ch, curlopt_url,$url); curl_setopt($ch, curlopt_nobody, 1); // 不下载 curl_setopt($ch, curlopt_failonerror, 1); curl_setopt($ch, curlopt_returntransfer, 1); if(curl_exec($ch)!==fal
function img_exits($url) { $ch = curl_init(); curl_setopt($ch, curlopt_url,$url); curl_setopt($ch, curlopt_nobody, 1); // 不下载 curl_setopt($ch, curlopt_failonerror, 1); curl_setopt($ch, curlopt_returntransfer, 1); if(curl_exec($ch)!==false) return true; else return false; } //方法二,代码如下: function img_exists($url) { if(file_get_contents($url,0,null,0,1)) return 1; else return 0; } // /** @title:如何检查某个远程文件是否存在(php5) @author:axgle @version:1.0 *//开源代码phpfensi.com $url='http://www.phpfensi.com/'; echo url_exists($url); function url_exists($url) { $head=@get_headers($url); if(is_array($head)) { return true; } return false; } ?> 网页方法,代码如下: <script language= "javascript"> function geturl(url) { var xmlhttp = new activexobject( "microsoft.xmlhttp "); xmlhttp.open( "get ",url,false); xmlhttp.send(); if (xmlhttp.readystate==4) alert((xmlhttp.status==200)? "文件存在 ": "文件不存在 "); } </script> 请输入文件地址: <input name= "file " id= "file " value= "http://www.phpfensi.com "> <button onclick= "geturl(file.value) "> 检测地址 </button> (编辑:开发网_郴州站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |