码迷,mamicode.com
首页 > 其他好文 > 详细

文件相关处理

时间:2018-08-27 18:30:09      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:strip   get   ipo   color   bsp   span   UNC   文件   code   

  常用的一些对于文件相关处理

  

一. 判断文件是否存在

// 验证文件是否存在
function existFile($file)
{
    if( empty($file) ) return false;

    if(stripos($file,http) === 0){
        // 远程图片
        $header = get_headers($file,1);
        return isset($header[0]) && (strpos($header[0],200) || strpos($header[0],304)) && stripos($header[0],OK);
    }else{
        // 验证是否有中文
        if(preg_match("/([\x81-\xfe][\x40-\xfe])/", $file, $match)){
            $file = iconv(UTF-8, GBK, $file);
        }
        return file_exists($file);
    }
}

  注: 匹配字符串全部是中文 

preg_match_all("/^([\x81-\xfe][\x40-\xfe])+$/", $str, $match)

  

 

文件相关处理

标签:strip   get   ipo   color   bsp   span   UNC   文件   code   

原文地址:https://www.cnblogs.com/xingxia/p/php_file.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!