file_unmanaged_prepare

function file_unmanaged_prepare

file_unmanaged_prepare($source, &$destination = NULL, $replace = FILE_EXISTS_RENAME)

Internal function that prepares the destination for a file_unmanaged_copy or file_unmanaged_move operation.

  • Checks if $source and $destination are valid and readable/writable.
  • Checks that $source is not equal to $destination; if they are an error is reported.
  • If file already exists in $destination either the call will error out, replace the file or rename the file based on the $replace parameter.

Parameters

$source: A string specifying the filepath or URI of the source file.

$destination: A URI containing the destination that $source should be moved/copied to. The URI may be a bare filepath (without a scheme) and in that case the default scheme (file://) will be used. If this value is omitted, Drupal's default