Documentation

CheckDirPath

CheckDirPath(
 string path,
 bool permissions = true
);

The function checks if a specified path physically exists. When required, the function creates all directories, included into this path.

Access permissions for which will be assigned by this function, must be preliminary defined in the BX_DIR_PERMISSIONS constant (in files /bitrix/php_interface/dbconn.php or /bitrix/php_interface/site ID/init.php). If the constant is not defined, it is automatically initialized with 0777, which will be further used for assigning Unix rights to files and directories.

Equivalent method in the new core: Bitrix\Main\IO\Directory::createDirectory .

Function parameters

ParameterDescription
abs_path Absolute path to the folder.
set_permissions If this parameter value is set to "true" and the last directory of the path specified in parameter abs_path is not available for writing, the attempt to assign new rights to this directory will be made. The values of these rights will be taken from constant BX_DIR_PERMISSIONS. If the constant is not defined, a value of 0777 is used.

See Also

  • [link=6658210]Access permissions for new files and directories[/link]

Examples of use

<?
// file /bitrix/php_interface/dbconn.php

// define constants for directories and files permissions
define("BX_FILE_PERMISSIONS", 0775);
define("BX_DIR_PERMISSIONS", 0775);
?>
<?
// Create a path "/temp/data/" starting from the root, if this path does not exist
CheckDirPath($_SERVER["DOCUMENT_ROOT"]."/temp/data/");
?>


© «Bitrix24», 2001-2024
Up