1. drupal
    1. 8
    2. 7
8 – 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.


$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 stream wrapper URI. If this value is omitted, Drupal's default files scheme will be used, usually "public://".

$replace Replace behavior when the destination file already exists:

Return value

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

See also


Related topics

▾ 6 functions call file_unmanaged_move()

FileUnmanagedMoveTest::testMissing in modules/simpletest/tests/file.test
Try to move a missing file.
FileUnmanagedMoveTest::testNormal in modules/simpletest/tests/file.test
Move a normal file.
FileUnmanagedMoveTest::testOverwriteSelf in modules/simpletest/tests/file.test
Try to move a file onto itself.
file_move in includes/
Move a file to a new location and update the file's database entry.
file_unmanaged_save_data in includes/
Save a string to the specified destination without invoking file API.
image_gd_save in modules/system/
GD helper to write an image resource to a destination file.


includes/, line 1068

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;