Title: {$action}_prefilter
Published: September 4, 2014
Last modified: April 28, 2025

---

# apply_filters( “{$action}_prefilter”, array $file )

## In this article

 * [Description](https://developer.wordpress.org/reference/hooks/action_prefilter/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/hooks/action_prefilter/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/action_prefilter/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/action_prefilter/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/action_prefilter/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/hooks/action_prefilter/?output_format=md#wp--skip-link--target)

Filters the data for a file before it is uploaded to WordPress.

## 󠀁[Description](https://developer.wordpress.org/reference/hooks/action_prefilter/?output_format=md#description)󠁿

The dynamic portion of the hook name, `$action`, refers to the post action.

Possible hook names include:

 * `wp_handle_sideload_prefilter`
 * `wp_handle_upload_prefilter`

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/action_prefilter/?output_format=md#parameters)󠁿

 `$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.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/action_prefilter/?output_format=md#source)󠁿

    ```php
    $file = apply_filters( "{$action}_prefilter", $file );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/file.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-admin/includes/file.php#L833)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-admin/includes/file.php#L833-L833)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/action_prefilter/?output_format=md#related)󠁿

| Used by | Description | 
| [_wp_handle_upload()](https://developer.wordpress.org/reference/functions/_wp_handle_upload/)`wp-admin/includes/file.php` |

Handles PHP uploads in WordPress.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/action_prefilter/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.0.0](https://developer.wordpress.org/reference/since/4.0.0/) | Converted to a dynamic hook with `$action`. | 
| [2.9.0](https://developer.wordpress.org/reference/since/2.9.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Faction_prefilter%2F)
before being able to contribute a note or feedback.