我想了一下,好像fscokopen可以判断返回的http头中有200没有刚刚网上也查了下,asp 的也是这个原理 <%
Function IsExi(url)
On Error Resume Next
IsExi= False
Set x = Server.CreateObject("Microsoft.xmlhttp")
x.Open "HEAD",url,false
x.send
IsExi= (x.status = 200)
End FunctionResponse.Write IsExi("http://xxx.com/xxx.zip")%>
Function IsExi(url)
On Error Resume Next
IsExi= False
Set x = Server.CreateObject("Microsoft.xmlhttp")
x.Open "HEAD",url,false
x.send
IsExi= (x.status = 200)
End FunctionResponse.Write IsExi("http://xxx.com/xxx.zip")%>
{
$handle = @fopen($fileName,"r");
if ($handle)
return true;
else
return false;
} 测试通过了
{
echo "Y";
}else{
echo "N";
}
或者网络不好
或者文件过大
就会造成当前页卡死现象
echo "y";
else
echo "b";
<?php
$timeout = 3;
$old = ini_set('default_socket_timeout', $timeout);
$file = fopen('http://example.com', 'r');
ini_set('default_socket_timeout', $old);
stream_set_timeout($file, $timeout);
stream_set_blocking($file, 0);
//the rest is standard
?>