apply_filters( 'pre_move_uploaded_file', mixed $move_new_file, array $file, string $new_file, string $type )
- Since
- 4.9.0
Filters whether to short-circuit moving the uploaded file after passing all checks.
Description
If a non-null value is returned from the filter, moving the file and any related error reporting will be completely skipped.
Compatibility
- WordPress
- since 4.9.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Parameters
$move_new_filemixed- If null (default) move the file after the upload.
$filearray- { 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.
}$namestringThe original name of the file on the client machine.$typestringThe mime type of the file, if the browser provided this information.$tmp_namestringThe temporary filename of the file in which the uploaded file was stored on the server.$sizeintThe size, in bytes, of the uploaded file.$errorintThe error code associated with this file upload.
$new_filestring- Filename of the newly-uploaded file.
$typestring- Mime type of the newly-uploaded file.
Where this hook fires · 1
wp-admin/includes/file.php:1010_wp_handle_upload()
Source code
* @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. */ $move_new_file = apply_filters( 'pre_move_uploaded_file', null, $file, $new_file, $type ); if ( null === $move_new_file ) { if ( 'wp_handle_upload' === $action ) { $move_new_file = @move_uploaded_file( $file['tmp_name'], $new_file ); } else { // Use copy and unlink because rename breaks streams.Changelog
Introduced in 4.9.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
- Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.