在网上找了找没有可以的
就是 我在发一个地址 http://www.xxx.net/file/123.rar
提交后 页面中 <a href"http://www.xxx.net/file/123.rar">123.rar</a>
让它可以自动检测文件是否存在
如果不存在 链接以这样的方式呈现
<a href"javascript:void(0)">文件链接无效</a>在网上找了下
php
<?php
$filename = 'http://www.xxx.net/file/123.rar';if (file_exists($filename)) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist";
}
?>
<?php
@$fp = fopen("http://www.xxx.net/file/123.rar", "r");
if($fp){
echo "链接正常";
}else {
echo "链接无效";
}
?>js function getURL(url)
{
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("GET",url,false);
xmlhttp.send();
if (xmlhttp.readyState==4)
alert((xmlhttp.Status==200)?"存在":"不存在");
}
//user like this:
getURL("http://www.xxx.net/file/123.rar")怎么让它可以在提交后检测呢
如果是在提交时 一个alert 如果是多个有效链接 其中夹带了几个无效的链接
那不是很棘手么
所以我想在提交后 页面上的地址中 如果包涵 无效的链接
就以<a href"javascript:void(0)">文件链接无效</a>这样的方式呈现
是否可以实现它呢
小弟没有分了 如果可以解决 攒3,400分偿还也是愿意的
就是 我在发一个地址 http://www.xxx.net/file/123.rar
提交后 页面中 <a href"http://www.xxx.net/file/123.rar">123.rar</a>
让它可以自动检测文件是否存在
如果不存在 链接以这样的方式呈现
<a href"javascript:void(0)">文件链接无效</a>在网上找了下
php
<?php
$filename = 'http://www.xxx.net/file/123.rar';if (file_exists($filename)) {
echo "The file $filename exists";
} else {
echo "The file $filename does not exist";
}
?>
<?php
@$fp = fopen("http://www.xxx.net/file/123.rar", "r");
if($fp){
echo "链接正常";
}else {
echo "链接无效";
}
?>js function getURL(url)
{
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("GET",url,false);
xmlhttp.send();
if (xmlhttp.readyState==4)
alert((xmlhttp.Status==200)?"存在":"不存在");
}
//user like this:
getURL("http://www.xxx.net/file/123.rar")怎么让它可以在提交后检测呢
如果是在提交时 一个alert 如果是多个有效链接 其中夹带了几个无效的链接
那不是很棘手么
所以我想在提交后 页面上的地址中 如果包涵 无效的链接
就以<a href"javascript:void(0)">文件链接无效</a>这样的方式呈现
是否可以实现它呢
小弟没有分了 如果可以解决 攒3,400分偿还也是愿意的
比如我在这里发一个文件的地址
实际上这个地址是无效的而
页面上的内容是 <a ref "javascript:void(0) "> 文件链接无效 </a>
function url_exists($url) {
// Version 4.x supported
$handle = curl_init($url);
if (false === $handle)
{
return false;
}
curl_setopt($handle, CURLOPT_HEADER, false);
curl_setopt($handle, CURLOPT_FAILONERROR, true); // this works
curl_setopt($handle, CURLOPT_HTTPHEADER, Array("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15") ); // request as if Firefox
curl_setopt($handle, CURLOPT_NOBODY, true);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, false);
$connectable = curl_exec($handle);
curl_close($handle);
return $connectable;
}$uri='http://www.rsywx.net/jquery/demos/index.html';
var_dump(url_exists($uri)); //true$uri='http://www.rsywx.net/jquery/demos/index1.html';
var_dump(url_exists($uri)); //false
?>需要激活curl的扩展。