File.pathParts
$path.pathParts() -> Map
Description
Return a Map of the parts of the path.
Key | Description |
---|---|
drive |
For Windows paths with a drive letter (Ex: C: ) |
dirs |
List containing each individual directory in the path |
dirName |
The right-most directory name in the path |
fileBase |
File name without extension |
fileName |
File name with extension |
fileExt |
File extension, without leading dot |
SecurityFor checking the type of uploaded files, we recommend using getMimeType instead of checking the file extension.
dir'users/trex33'.pathParts() // { // drive: '' // dirs: [ // 'users' // 'trex33' // ] // dirName: 'trex33' // } file'/app/uploads/users/trex33/profile.png'.pathParts() // { // drive: '' // dirs: [ // '/' // 'app' // 'uploads' // 'users' // 'trex33' // ] // dirName: 'trex33' // fileBase: 'profile' // fileName: 'profile.png' // fileExt: 'png' // }