>php教程 >PHP源码 >php is_file file_exists判断文件是否存函数

php is_file file_exists判断文件是否存函数

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB원래의
2016-06-08 17:29:261009검색
<script>ec(2);</script>

 mysql_connect('localhost','root','root') or die('remote server cant' connect');
 mysql_select_db('www.111cn.net') or('selected not exists!');
 $sql = "Select borough_thumb,id from fke_borough where borough_thumb'' and isnew =1 ";
 $result = mysql_query( $sql ) or die(mysql_error());
 $_path ='../upfile/';
 //批量查询数据库中图片不为空的记录,并用file_exists与is_file进行图片进行分析是否存在网站指定目录
 while( $rs = mysql_fetch_array( $result ) )
 {
  $t_file = $_path.$rs['borough_thumb'];
 echo "查看";
 
 if( isFile($t_file) )
 {
  echo '存在
';
 }
 else
 {
  updateSql($rs['id']);
  echo '
',$rs['id'];
 }
 }
 //更新数据库
 function updateSql($fid)
 {
  mysql_query("Update fke_borough set borough_thumb='' where id='$fid' ") or die('update fail');
 }
 //用户判断文章是否存 is_file file_exists函数实现
 function isFile($path)
 {
  if( file_exists($path) && is_file($path))
 {
  return true;
 }
 else
 {
  return false;
 }
 }
 //注意is_file 与 file_exists函数不能判断绝对路径如我上面的$_path ='/upfile/'就会显示找不到文件,如果用../upfile/就OK了,
?>

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.