| 5 file.inc | file_create_path($dest = 0) |
| 6 file.inc | file_create_path($dest = 0) |
Make sure the destination is a complete path and resides in the file system directory, if it is not prepend the file system directory.
Parameters
$dest A string containing the path to verify. If this value is: omitted, Drupal's 'files' directory will be used.
Return value
A string containing the path to file, with file system directory appended if necessary, or FALSE if the path is invalid (i.e. outside the configured 'files' or temp directories).
Related topics
15 calls to file_create_path()
File
- includes/
file.inc, line 63 - API for handling file uploads and server file management.
Code
function file_create_path($dest = 0) {
$file_path = file_directory_path();
if (!$dest) {
return $file_path;
}
// file_check_location() checks whether the destination is inside the Drupal files directory.
if (file_check_location($dest, $file_path)) {
return $dest;
}
// check if the destination is instead inside the Drupal temporary files directory.
else if (file_check_location($dest, file_directory_temp())) {
return $dest;
}
// Not found, try again with prefixed directory path.
else if (file_check_location($file_path . '/' . $dest, $file_path)) {
return $file_path . '/' . $dest;
}
// File not found.
return FALSE;
}
Login or register to post comments
Comments
dropped in drupal 7. See:
dropped in drupal 7. See: http://drupal.org/node/613918
The name of this function can
The name of this function can be misleading at first. This creates a path as in it will return a string with the potential path ;). If you are actually looking to create the path in the file system, as in create directories if they don't exist, you have to do something like this:
<?php
$path = file_create_path("some_path");
file_check_directory($path, FILE_CREATE_DIRECTORY);
?>