1

I use class.upload Version 0.32 and it works correctly on my localhost server, but it does not work on my web server.

The web server log file shows this error:

PHP Warning:  preg_match(): Compilation failed: invalid range in character class at offset 7 in.

PHP version on web server: 5.4.39

PHP version on localhost: 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 .= '-&nbsp;MIME validated as ' . $this->file_src_mime . '<br />';
} else {
    $this->file_src_mime = null;
}
0

1 Answer 1

2

You have to escape the dash:

/^([\.\-\w]+)\/([\.\-\w]+)(.*)$/i

or put it at the end or begining of the character class

/^([-\.\w]+)\/([-\.\w]+)(.*)$/i

and the dot doesn't need to be escaped nor the case insensitive :

/^([_.\w]+)\/([-.\w]+)(.*)$/
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.