file_unmanaged_move
function file_unmanaged_move
file_unmanaged_move($source, $destination = NULL, $replace = FILE_EXISTS_RENAME)
Moves a file to a new location without database changes or hook invocation.
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 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:
- 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.
See also
Related topics
File
- includes/file.inc, line 1107
- API for handling file uploads and server file management.
Code
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; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!file.inc/function/file_unmanaged_move/7.x