FileValidatorModule class
Base class for FileValidator modules, which validate uploaded files.
To create a FileValidator module:
- Create a class that extends this and follow the naming convention:
FileValidator[Something]
. - Place in file: /site/modules/FileValidator[Something].module (or in module-specific directory).
- Copy the
getModuleInfo()
method out of this class and update as appropriate. - Implement an
isValidFile($filename)
method, and you are done.
Example: /site/modules/FileValidatorHTML.module
class FileValidatorHTML extends FileValidatorModule {
public static function getModuleInfo() {
return array(
'title' => 'Validate HTML files',
'version' => 1,
'validates' => array('html', 'htm'),
);
}
protected function isValidFile($filename) {
$valid = false;
// some code to validate $filename and set $valid
return $valid;
}
}
Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the File
class also inherits all the methods and properties of: WireData and Wire.
Common
Additional methods and properties
In addition to the methods and properties above, File
API reference based on ProcessWire core version 3.0.251