wphooks.info - pre_move_uploaded_file

pre_move_uploaded_file

(trunk - 5.0-alpha-42177)

*** New in trunk ***

The hook occurs in the following file:

wp-admin/includes/file.php:
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
	 * If a non-null value is passed to the filter, moving the file and any related error
	 * reporting will be completely skipped.
	 *
	 * @since 4.9.0
	 *
	 * @param string $move_new_file If null (default) move the file after the upload.
	 * @param string $file          An array of data for a single file.
	 * @param string $new_file      Filename of the newly-uploaded file.
	 * @param string $type          File type.
	 */
	$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.
			$move_new_file = @ copy( $file['tmp_name'], $new_file );
			unlink( $file['tmp_name'] );
		}