我使用class.upload
版本0.32,它在我的本地主机服务器上工作正常,但它在我的Web服务器上不起作用。
Web 服务器日志文件显示此错误:
PHP Warning: preg_match(): Compilation failed: invalid range in character class at offset 7 in.
网络服务器上的PHP版本:5.4.39
本地主机上的 PHP 版本:5.5.15
if (preg_match("/^([.-w]+)/([.-w]+)(.*)$/i", $this->file_src_mime)) {
$this->file_src_mime = preg_replace("/^([.-w]+)/([.-w]+)(.*)$/i", '$1/$2', $this->file_src_mime);
$this->log .= '- MIME validated as ' . $this->file_src_mime . '<br />';
} else {
$this->file_src_mime = null;
}
你必须转义破折号:
/^([.-w]+)/([.-w]+)(.*)$/i
或将其放在字符类的末尾或开头
/^([-.w]+)/([-.w]+)(.*)$/i
点不需要转义,也不需要区分大小写:
/^([_.w]+)/([-.w]+)(.*)$/