WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do you use wp_handle_upload function and apply_filter together to upload files on a specific path? What is going to be the override?

For example:

$overrides = array('file' => 'C:\\uploads\\filename.pdf','message' => 'File written');

or something like that? Or is this the right code?

The real question in here is: what $overrides can be used as the key to this associative array?

share|improve this question
up vote 0 down vote accepted

You need to specify a list of allowed mime types.

You could make it easy by just getting the allowed mime types like:

$file = $_FILES['the-file'];
$upload_file = wp_handle_upload($file, array(
    'test_form' => false,
    'mimes' => get_allowed_mime_types()

If you look at the codex for Default allowed mime types, you could manually specify which ever mime types you want in that format.

An example would be like this answer.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.