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

<?php
 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 "<a href=$t_file target=_blank>查看</a>";
 
 if( isFile($t_file) )
 {
  echo '存在<br/>';
 }
 else
 {
  updateSql($rs['id']);
  echo '<br>',$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了,
?>

时间: 2024-08-26 11:55:05

php is_file file_exists判断文件是否存函数的相关文章

Lua获取文件长度和判断文件是否存在函数

  这篇文章主要介绍了Lua获取文件长度和判断文件是否存在函数分享,需要的朋友可以参考下 获得文件长度 代码如下: function length_of_file(filename) local fh = assert(io.open(filename, "rb")) local len = assert(fh:seek("end")) fh:close() return len end 判断文件是否存在 代码如下: function file_exists(pat

Lua获取文件长度和判断文件是否存在函数分享_Lua

获得文件长度 复制代码 代码如下:  function length_of_file(filename)   local fh = assert(io.open(filename, "rb"))   local len = assert(fh:seek("end"))   fh:close()   return len end 判断文件是否存在 复制代码 代码如下: function file_exists(path)   local file = io.open(

php file_exists 判断文件是否存在,是返回ture或1 否返回false或0

 file_exists($filename);  */    $file ='www.111cn.net.txt';    if( file_exists( $file ) )  {   echo $file,'存在';  }  else  {   echo $file,'不存在,请查检路径或文件名是否写正确了';  }      // 本文章原创于www.111cn.net 转载注明出处

php中is_dir,is_file,file_exists函数性能分析

php中is_dir,is_file,file_exists函数性能分析 php,is_dir,is_file,file_exists 很显然file_exists是受了asp的影响,因为asp不但有fileExists还有folderExists,driverExists,那么PHP中file_exists是什么意思呢? PHP的 file_exists = is_dir + is_file 它既可以判断文件是否存在,又可以判断目录是否存在.但这样一个全面的函数执行效率非常低,就像asp中re

PHP中判断文件存在使用is_file还是file_exists?_php技巧

判断文件存在用is_file还是file_exists? 在写程序时发现在判断文件是否存在时,有两种写法,有的人用了is_file,有的人用了file_exists,用哪个更好或者说更合适呢? 看了这篇PHP中file_exists与is_file,is_dir的区别的说法基本明白,PHP的 file_exists = is_dir + is_file. 写程序验证一下: 分别执行1000次,记录所需时间. 文件存在(当前目录) 复制代码 代码如下: is_file:0.4570ms file_

php中判断文件存在是用file_exists还是is_file的整理_php技巧

看了这篇PHP中file_exists与is_file,is_dir的区别的说法基本明白,PHP的 file_exists = is_dir + is_file. 写程序验证一下: 分别执行1000次,记录所需时间. 文件存在(当前目录) is_file:0.4570ms file_exists:2.0640ms 文件存在(绝对路径3层/www/hx/a/) is_file:0.4909ms file_exists:3.3500ms 文件存在(绝对路径5层/www/hx/a/b/c/) is_f

php判断文件是否存在file_exists 与 is_file详解

php教程判断文件是否存在file_exists 与 is_file详解 $file ='新建 文本    文档.txt'; $file1 ='a.txt'; list($name,$ext) = explode('.',$file); echo $name;   if( is_file( $name.'.txt' ) ) {  echo 'file存在'; } if( file_exists( $file1 ) ) {  echo 'file1存在'; }

php is_file 判断文件存在

//用户判断文章是否存 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/'就会显示找不到文件,如果用../up

php中判断文件空目录是否有读写权限的函数代码_php技巧

is_writable用来处理,记住 PHP 也许只能以运行 webserver 的用户名(通常为 \'nobody\')来访问文件.不计入安全模式的限制. Example #1 is_writable() 例子 复制代码 代码如下: <?php $filename = 'test.txt'; if (is_writable($filename)) { echo 'The file is writable'; } else { echo 'The file is not writable'; }