pre_move_uploaded_file
Filter HookDescription
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. }Hook Information
| File Location | wp-admin/includes/file.phpView on GitHub | 
| Hook Type | Filter | 
| Line Number | 1010 | 
Hook Parameters
| Type | Name | Description | 
|---|---|---|
| mixed | $move_new_file | If null (default) move the file after the upload. | 
| array | $file | { Reference to a single element from `$_FILES`. | 
| string | $new_file | Filename of the newly-uploaded file. | 
| string | $type | Mime type of the newly-uploaded file. | 
Usage Examples
                        Basic Usage
                    
                    <?php
// Hook into pre_move_uploaded_file
add_filter('pre_move_uploaded_file', 'my_custom_filter', 10, 4);
function my_custom_filter($move_new_file, $file, $new_file, $type) {
    // Your custom filtering logic here
    return $move_new_file;
}
Source Code Context
                        wp-admin/includes/file.php:1010
                        - How this hook is used in WordPress core
                    
                    <?php
1005  	 *     @type int    $error    The error code associated with this file upload.
1006  	 * }
1007  	 * @param string   $new_file      Filename of the newly-uploaded file.
1008  	 * @param string   $type          Mime type of the newly-uploaded file.
1009  	 */
1010  	$move_new_file = apply_filters( 'pre_move_uploaded_file', null, $file, $new_file, $type );
1011  
1012  	if ( null === $move_new_file ) {
1013  		if ( 'wp_handle_upload' === $action ) {
1014  			$move_new_file = @move_uploaded_file( $file['tmp_name'], $new_file );
1015  		} else {
PHP Documentation
<?php
/**
	 * 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.
	 *
	 * @since 4.9.0
	 *
	 * @param mixed    $move_new_file If null (default) move the file after the upload.
	 * @param array    $file          {
	 *     Reference to a single element from `$_FILES`.
	 *
	 *     @type string $name     The original name of the file on the client machine.
	 *     @type string $type     The mime type of the file, if the browser provided this information.
	 *     @type string $tmp_name The temporary filename of the file in which the uploaded file was stored on the server.
	 *     @type int    $size     The size, in bytes, of the uploaded file.
	 *     @type int    $error    The error code associated with this file upload.
	 * }
	 * @param string   $new_file      Filename of the newly-uploaded file.
	 * @param string   $type          Mime type of the newly-uploaded file.
	 */
                        Quick Info
                    
                    - Hook Type: Filter
- Parameters: 4
- File: wp-admin/includes/file.php
                        Related Hooks
                    
                    Related hooks will be displayed here in future updates.
