SilverStripe\MimeValidator\MimeUploadValidator
Adds an additional validation rule to Upload_Validator that attempts to detect the file extension of an uploaded file matches it's contents, which is done by detecting the MIME type and doing a fuzzy match.
Class MimeUploadValidator
Synopsis
class MimeUploadValidator
extends Upload_Validator
{
- // members
- protected string $filterPattern = '/.*[\/\.\-\+]/i';
- // methods
- public void setFilterPattern()
- public string getFilterPattern()
- public bool|null isValidMime()
- public array getExpectedMimeTypes()
- public boolean compareMime()
- public void validate()
Hierarchy
Extends
- SilverStripe\Assets\Upload_Validator
Members
protected
- $filterPattern
—
string
The preg_replace() pattern to use against MIME types. Used to strip out useless characters so matching of MIME types can be fuzzy.
Methods
public
- compareMime() — Check two MIME types roughly match eachother.
- getExpectedMimeTypes() — Fetches an array of valid mimetypes.
- getFilterPattern()
- isValidMime() — Check if the temporary file has a valid MIME type for it's extension.
- setFilterPattern()
- validate()