zoukankan      html  css  js  c++  java
  • php检查上传文件是否已存在或同名

    简介:这是php检查上传文件是否已存在或同名的详细页面,介绍了和php,php, file, path, 文件 php检查上传文件是否已存在或同名有关的知识、技巧、经验,和一些php源码等。

    class='pingjiaF' frameborder='0' src='http://biancheng.dnbcw.info/pingjia.php?id=344669' scrolling='no'>

    //检查上传文件的目录里是否已存在同名的上传文件

    function searchFile($path,$file){
    	$file_array=array(); //存放文件名数组
    	$folder_array=array(); //存放目录名数组
    	$all_array=array(); //存放全部路径的数组
    
    	if(is_dir($path)){  //检查文件目录是否存在
    		$H = @ opendir($path);
    		while(false !== ($_file=readdir($H))){
    			//检索目录
    			if(is_dir($path."/".$_file) && $_file != "." && $_file!=".." && $_file!=="Thumbs.db"){
    				if(eregi('/'.$file,'/'.$_file)){
    					array_push($folder_array,$path."/".$_file);
    				}
    				searchFile($path."/".$_file,$file);
    			//检索文件
    			}elseif(is_file($path."/".$_file) && $_file!="." && $_file!=".." && $_file!=="Thumbs.db"){
    				echo $_file;
    				echo '<br>';
    				//$_file = auto_charset($_file,'utf-8','gbk');
    				if(eregi('/'.$file,'/'.$_file)){
    					array_push($file_array,$path."/".$_file);
    					return 'yes'; //文件存在
    				}
    			}
    		}
    		//$this->all_array["folder"]=$this->folder_array;
    		//$this->all_array["file"]=$this->file_array;
    		closedir($H);
    		return 'no'; //不存在
    	}elseif(is_file($path)){
    		if(eregi($file,$path)){
    			//$this->all_array["file"]=$path;
    			return 'yes'; //文件存在
    		} else {
    			return 'no'; //文件不存在
    		}
    	}else{
    		return 'no'; //文件不存在
    	}
    }

    爱J2EE关注Java迈克尔杰克逊视频站JSON在线工具

    http://biancheng.dnbcw.info/php/344669.html pageNo:4
  • 相关阅读:
    learning.py报错
    Swift与OC的相互调用
    微信小程序地图之逆地理编码
    微信小程序-滑动视图注意事项
    animate.css动画种类
    利用WKWebView实现js与OC交互注意事项
    jquey下eq()的使用注意事项
    如何判断html页面停止滚动?
    git 常见报错
    openresty中http请求body数据过大的处理方案
  • 原文地址:https://www.cnblogs.com/ooooo/p/2240623.html
Copyright © 2011-2022 走看看