$sanitizer->validateFile() method

Validate a file using FileValidator modules

Note that this is intended for validating file data, not file names.

IMPORTANT: This method returns NULL if it can't find a validator for the file. This does not mean the file is invalid, just that it didn't have the tools to validate it.

Usage

// basic usage
$bool = $sanitizer->validateFile(string $filename);

// usage with all arguments
$bool = $sanitizer->validateFile(string $filename, array $options = []);

Arguments

NameType(s)Description
filenamestring

Full path and filename to validate

options (optional)array

When available, provide array with any one or all of the following:

  • page (Page): Page object associated with $filename.
  • field (Field): Field object associated with $filename.
  • pagefile (Pagefile): Pagefile object associated with $filename.

Return value

bool null

Returns TRUE if valid, FALSE if not, or NULL if no validator available for given file type.


$sanitizer methods and properties

API reference based on ProcessWire core version 3.0.137

Twitter updates

  • ProcessWire 3.0.146 on the dev branch contains about 22 commits with a combination of useful upgrades and issue report resolutions, more details in this forum post: More
    22 November 2019
  • ProcessWire 3.0.144 and 3.0.145 add improved field template context override settings and include a new Inputfields API, along with numerous other issue fixes, optimizations and improvements to the core. More
    8 November 2019
  • ProcessWire 3.0.144 core updates: Upgraded overrides section in the field editor, a new Inputfields JS API, and more— More
    1 November 2019

Latest news

  • ProcessWire Weekly #290
    In the 290th issue of ProcessWire Weekly we're going to introduce the latest addition to the ProDevTools module package and a third party image picker field from gebeer, check out a new site of the week, and more. Read on!
    Weekly.pw / 30 November 2019
  • New User Activity module
    Blog / 29 November 2019
  • Subscribe to weekly ProcessWire news

“To Drupal, or to ProcessWire? The million dollar choice. We decided to make an early switch to PW. And in retrospect, ProcessWire was probably the best decision we made. Thanks are due to ProcessWire and the amazing system and set of modules that are in place.” —Unni Krishnan, Founder of PigtailPundits