Bitrix Site Manager

CheckDirPath

CheckDirPath(
 string abs_path,
 bool set_permissions = true
)

The function CheckDirPath checks if the path specified physically exists. Creates all directories of the path, if necessary.

Note!
The rights for directories 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 asigning Unix rights to files and directories.

Parameters

ParameterDescription
abs_path Absolute path to the folder.
set_permissions If 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

Example



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

// define constants for files and directories 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");
?>