$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.155

Twitter updates

  • This post covers a few of the bigger updates in ProcessWire 3.0.154+3.0.155. This includes new live replacement of text in core and modules, a new method for creating canonical URLs, and some major upgrades to our input->urlSegment() method! More
    24 April 2020
  • A brief look at what's new in ProcessWire 3.0.154 in this forum post: More
    17 April 2020
  • This week we’ve got a few new and interesting core updates in progress, though none quite ready to release just yet. So rather than releasing version 3.0.154 today, I thought we'd instead take a brief look at what’s coming over the next few weeks… More
    3 April 2020

Latest news

  • ProcessWire Weekly #310
    The 310th issue of ProcessWire Weekly is going to be short and sweet: in this issue we'll walk you through the latest core updates, introduce a third party module called Twack, and check out a really gorgeous new site of the week. Read on!
    Weekly.pw / 18 April 2020
  • ProcessWire updates and additions in progress
    This week we’ve got a few new and interesting core updates in progress, though none quite ready to release just yet. So rather than releasing version 3.0.154 today, I thought we'd instead take a brief look at what’s coming over the next few weeks. This post covers all the details.
    Blog / 3 April 2020
  • Subscribe to weekly ProcessWire news

“I am currently managing a ProcessWire site with 2 million+ pages. It’s admirably fast, and much, much faster than any other CMS we tested.” —Nickie, Web developer