函数代码

function is_valid_filename($name) 
{
  $parts = preg_split("/(\/|".preg_quote("\\").")/", $name);
  if (preg_match("/[a-z]:/i", $parts[0])) {
    unset($parts[0]);
  }
  foreach ($parts as $part) 
  {
    print "part = '$part'<br>";
    if (preg_match("/[".preg_quote("^|":>", "/")."\a\b\c\e\x\v\s]/", $part) || preg_match("/^(PRN|CON|AUX|CLOCK$|NUL|COMd|LPTd)$/im", 
    str_replace(".", "\n", $part))) {
      return false;
    }
  }
  return true;
}
$bad = array_merge(array_map('chr', range(0, 31)), array("<", ">", ":", '"', "/", "\\", "|", "", "*"));
$result = str_replace($bad, "", $filename); 

windows 系统文件命名规则限制

https://msdn.microsoft.com/en-us/library/aa365247

华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com