file_create_path

Versions
4.6 – 6
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 Path to verify

Return value

Path to file with file system directory appended if necessary. Returns FALSE if the path is invalid (i.e. outside the configured 'files'-directory).

Related topics

▾ 10 functions call file_create_path()

fileupload_file_download in developer/examples/fileupload.module
file_copy in includes/file.inc
Copies a file to a new location. This is a powerful function that in many ways performs like an advanced version of copy().
file_download in includes/file.inc
Call modules to find out if a file is accessible for a given user.
file_transfer in includes/file.inc
Transfer file using http to client. Pipes a file through Drupal to the client.
upload_file_download in modules/upload.module
upload_form in modules/upload.module
upload_menu in modules/upload.module
Implementation of hook_menu().
upload_nodeapi in modules/upload.module
Implementation of hook_nodeapi().
user_configure_settings in modules/user.module
user_file_download in modules/user.module
Implementation of hook_file_download().

Code

includes/file.inc, line 51

<?php
function file_create_path($dest = 0) {
  $file_path = variable_get('file_directory_path', 'files');
  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, variable_get('file_directory_temp', FILE_DIRECTORY_TEMP))) {
    return $dest;
  }
  // Not found, try again with prefixed dirctory 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
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.