file_unmanaged_move

Versions
7
file_unmanaged_move($source, $destination = NULL, $replace = FILE_EXISTS_RENAME)

Move a file to a new location without calling any hooks or making any changes to the database.

See also

file_move()

Parameters

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

$destination A string containing the destination that $source should be moved to. This must be a URI matching a Drupal stream wrapper. If this value is omitted, Drupal's 'files' directory will be used.

$replace Replace behavior when the destination file already exists:

  • FILE_EXISTS_REPLACE - Replace the existing file.
  • FILE_EXISTS_RENAME - Append _{incrementing number} until the filename is unique.
  • FILE_EXISTS_ERROR - Do nothing and return FALSE.

Return value

The URI of the moved file, or FALSE in the event of an error.

Related topics

▾ 2 functions call file_unmanaged_move()

file_move in includes/file.inc
Move a file to a new location and update the file's database entry.
file_unmanaged_save_data in includes/file.inc
Save a string to the specified destination without calling any hooks or making any changes to the database.

Code

includes/file.inc, line 790

<?php
function file_unmanaged_move($source, $destination = NULL, $replace = FILE_EXISTS_RENAME) {
  $filepath = file_unmanaged_copy($source, $destination, $replace);
  if ($filepath == FALSE || file_unmanaged_delete($source) == FALSE) {
    return FALSE;
  }
  return $filepath;
}
?>
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.