FILE Methods

directory()

Get filename and formatted directory or create directory. Please be careful when using this function since it gives you full access to all system files and directories. For futher information on how to use this function and for a comparrison between this and alternative methods see our directory example!

string directory([ string name [, int format = 3 [, int root = 0 [, bool create = false ]]]])

Return

Formatted file and directory name

Parameter
Description
nameName of file and/or directory (see examples below)
format1 = relative path: dir/...
2 = absolute path: /dir/...
3 = root path: SERVERROOT/dir/...
root0 = /
1 = admin/
2 = config/
3 = data/
4 = libs/
5 = modules/
6 = system/
7 = templates/
createCreate directory if it doesn't exist.

Get project's root directory

$FILE->directory()
RETURN: '/var/.../.../'

Get filename and path of a file in the root-directory

$FILE->directory("robots.txt")
RETURN: '/var/.../.../robots.txt'

Get absolute path of file in libaries directory

$FILE->directory("test.js", 2, 4)
RETURN: '/libs/test.js'

Create test directory inside data-directory and return relative path

$FILE->directory("temp/test/subdir/", 1, 3, true)
RETURN: 'data/temp/test/subdir/'