1

validatefilename

validate_filename
SYNOPSIS

validate_filename($name)

DESCRIPTION

validate_filename returns true if $name is a valid file name, false otherwise.

CODE
  1. function validate_filename($name) {
  2.     return preg_match('/^[[:alpha:]]+[[:alnum:]_-]*(\.[[:alnum:]]+)?$/', $name);
  3. }

validate_filename returns true if $name starts with an alphabetic character followed by a series of alphanumeric characters, a dot and at least one alphanumeric character.

SEE ALSO

isfilenameallowed

Comments

To add a comment, click here.