file_move(&$source, $dest = 0, $replace = FILE_EXISTS_RENAME)
drupal/includes/file.inc, line 414
Moves a file to a new location.
$source A string specifying the file location of the original file. This parameter will contain the resulting destination filename in case of success.
$dest A string containing the directory $source should be copied to. If this value is omitted, Drupal's 'files' directory will be used.
$replace Replace behavior when the destination file already exists.
True for success, false for failure.
| Name | Description |
|---|---|
| File interface | Common file handling functions. |
function file_move(&$source, $dest = 0, $replace = FILE_EXISTS_RENAME) {
$path_original = is_object($source) ? $source->filepath : $source;
if (file_copy($source, $dest, $replace)) {
$path_current = is_object($source) ? $source->filepath : $source;
if ($path_original == $path_current || file_delete($path_original)) {
return 1;
}
drupal_set_message(t('The removal of the original file %file has failed.', array('%file' => theme('placeholder', $path_original))), 'error');
}
return 0;
}