CakeFest 2025 Madrid: The Official CakePHP Conference

Voting

: two minus two?
(Example: nine)

The Note You're Voting On

solixmexico at outlook dot com
8 years ago
To validate directorys on Windows i used this:

if( preg_match("#^([a-z]{1}\:{1})?[\\\/]?([\-\w]+[\\\/]?)*$#i",$_GET['path'],$matches) !== 1 ){
echo("Invalid value");
}else{
echo("Valid value");
}

The parts are:

#^ and $i Make the string matches at all the pattern, from start to end for ensure a complete match.
([a-z]{1}\:{1})? The string may starts with one letter and a colon, but only 1 character for eachone, this is for the drive letter (C:)
[\\\/]? The string may contain, but not require 1 slash or backslash after the drive letter, (\/)
([\-\w]+[\\\/]?)* The string must have 1 or more of any character like hyphen, letter, number, underscore, and may contain a slash or back slash at the end, to have a directory like ("/" or "folderName" or "folderName/"), this may be repeated one or more times.

<< Back to user notes page

To Top