diff --git a/core/includes/file.inc b/core/includes/file.inc
index e532bf1..5f1361be 100644
--- a/core/includes/file.inc
+++ b/core/includes/file.inc
@@ -926,17 +926,39 @@ function file_unmanaged_delete_recursive($path, $callback = NULL) {
   return file_unmanaged_delete($path);
 }
 
-
 /**
  * Moves an uploaded file to a new location.
  *
+ * PHP's move_uploaded_file() does not properly support URIs if safe_mode or
+ * open_basedir are enabled, so this function fills that gap for local URIs.
+ *
+ * move_uploaded_file() is also very inefficient when supplied with URIs as it
+ * will perform a copy and then a delete. With this function, if the destination
+ * URI scheme supports the realpath() method, i.e. it is a local scheme, then
+ * the I/O produced will be negligible.
+ *
+ * Compatibility: normal paths and stream wrappers.
+ *
+ * @param $filename
+ *   The filename of the uploaded file.
+ * @param $uri
+ *   A string containing the destination URI of the file.
+ *
+ * @return
+ *   TRUE on success, or FALSE on failure.
+ *
+ * @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0.
+ *   Use \Drupal\Core\File\FileSystem::realpath().
+ *
  * @deprecated in Drupal 8.0.x-dev, will be removed before Drupal 9.0.0.
  *   Use \Drupal\Core\File\FileSystem::moveUploadedFile().
  *
  * @see https://www.drupal.org/node/2418133
  */
 function drupal_move_uploaded_file($filename, $uri) {
-  return \Drupal::service('file_system')->moveUploadedFile($filename, $uri);
+	// Resolve the destination URI if posible.
+	$destination = drupal_realpath($uri) ?: $uri;
+	return \Drupal::service('file_system')->moveUploadedFile($filename, $destination);
 }
 
 /**
