Commit 431915c4 by MarcioCamello

mimeTypes Validator is wrong

I'm find error ```php Wrong } elseif (!empty($this->mimeTypes) && !in_array(FileHelper::getMimeType($file->tempName), $this->mimeTypes, true)) { Correct } elseif (!empty($this->mimeTypes) && !in_array(FileHelper::getMimeType($file), $this->mimeTypes, true)) { ``` Not need call '$file->tempName' because getMimeType get object $_FILE => $file, so use $file and validator works fine
parent 0d92cb4a
...@@ -205,7 +205,7 @@ class FileValidator extends Validator ...@@ -205,7 +205,7 @@ class FileValidator extends Validator
return [$this->tooSmall, ['file' => $file->name, 'limit' => $this->minSize]]; return [$this->tooSmall, ['file' => $file->name, 'limit' => $this->minSize]];
} elseif (!empty($this->types) && !in_array(strtolower(pathinfo($file->name, PATHINFO_EXTENSION)), $this->types, true)) { } elseif (!empty($this->types) && !in_array(strtolower(pathinfo($file->name, PATHINFO_EXTENSION)), $this->types, true)) {
return [$this->wrongType, ['file' => $file->name, 'extensions' => implode(', ', $this->types)]]; return [$this->wrongType, ['file' => $file->name, 'extensions' => implode(', ', $this->types)]];
} elseif (!empty($this->mimeTypes) && !in_array(FileHelper::getMimeType($file->tempName), $this->mimeTypes, true)) { } elseif (!empty($this->mimeTypes) && !in_array(FileHelper::getMimeType($file), $this->mimeTypes, true)) {
return [$this->wrongMimeType, ['file' => $file->name, 'mimeTypes' => implode(', ', $this->mimeTypes)]]; return [$this->wrongMimeType, ['file' => $file->name, 'mimeTypes' => implode(', ', $this->mimeTypes)]];
} else { } else {
return null; return null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment