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