You are here

function file_create_path in Drupal 4

Same name and namespace in other branches
  1. 5 includes/file.inc \file_create_path()
  2. 6 includes/file.inc \file_create_path()

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

10 calls to file_create_path()
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 that implement hook_file_download() to find out if a file is accessible and what headers it should be transferred with. If a module returns -1 drupal_access_denied() will be returned. If one or more modules returned headers the download…
file_transfer in includes/file.inc
Transfer file using http to client. Pipes a file through Drupal to the client.
theme_upload_attachments in modules/upload.module
Displays file attachments in table
upload_file_download in modules/upload.module

... See full list

File

includes/file.inc, line 51
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;
  }
  else {
    if (file_check_location($dest, file_directory_temp())) {
      return $dest;
    }
    else {
      if (file_check_location($file_path . '/' . $dest, $file_path)) {
        return $file_path . '/' . $dest;
      }
    }
  }

  // File not found.
  return FALSE;
}