pre_move_uploaded_file filter-hookWP 4.9.0

Filters whether to short-circuit moving the uploaded file after passing all checks.

If a non-null value is returned from the filter, moving the file and any related error reporting will be completely skipped.

Usage

add_filter( 'pre_move_uploaded_file', 'wp_kama_pre_move_uploaded_file_filter', 10, 4 );

/**
 * Function for `pre_move_uploaded_file` filter-hook.
 * 
 * @param mixed  $move_new_file If null (default) move the file after the upload.
 * @param array  $file          Reference to a single element from `$_FILES`.
 * @param string $new_file      Filename of the newly-uploaded file.
 * @param string $type          Mime type of the newly-uploaded file.
 *
 * @return mixed
 */
function wp_kama_pre_move_uploaded_file_filter( $move_new_file, $file, $new_file, $type ){

	// filter...
	return $move_new_file;
}
$move_new_file(mixed)
If null (default) move the file after the upload.
$file(array)

Reference to a single element from $_FILES.

  • name(string)
    The original name of the file on the client machine.

  • type(string)
    The mime type of the file, if the browser provided this information.

  • tmp_name(string)
    The temporary filename of the file in which the uploaded file was stored on the server.

  • size(int)
    The size, in bytes, of the uploaded file.

  • error(int)
    The error code associated with this file upload.
$new_file(string)
Filename of the newly-uploaded file.
$type(string)
Mime type of the newly-uploaded file.

Changelog

Since 4.9.0 Introduced.

Where the hook is called

_wp_handle_upload()
pre_move_uploaded_file
wp-admin/includes/file.php 979
$move_new_file = apply_filters( 'pre_move_uploaded_file', null, $file, $new_file, $type );

Where the hook is used in WordPress

Usage not found.