apply_filters( 'wp_handle_upload_prefilter', array $file )

Filter data for the current file to upload.

Parameters Parameters


(array) An array of data for a single file.

Top ↑

Source Source

File: wp-admin/includes/file.php

View on Trac

Top ↑

Changelog Changelog

Version Description
2.9.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 2 content
    Contributed by Jules Colle

    Example: prepend all uploaded files with wordpress-is-awesome-

    add_filter( 'wp_handle_upload_prefilter', function( $file ) {
        $file['name'] = 'wordpress-is-awesome-' . $file['name'];
        return $file;
    } );

    (According to this code was originally in the docs. I’m adding it here again since I can’t find it anywhere else.)

You must log in before being able to contribute a note or feedback.