Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to work out how to use the wp_handle_upload function for a custom plugin so that i can specify my own own upload directory. The code so far takes a file from my plugin settings page and uploads to the folder uploads folder with the year and month.

I came across this link which I thought might have some clues - http://yoast.com/smarter-upload-handling-wp-plugins

if(strtolower($_SERVER['REQUEST_METHOD']) == "post"){

     $overrides = array('test_form' => false);
     $file = wp_handle_upload($_FILES['binaryFile'], $overrides);

     echo "<pre>" . print_r($file, true) . "</pre>";
}

How can I upload to a directory of my choosing?

Any help much appreciated guys.

share|improve this question

1 Answer

I don't remember doing exactly this in practice, but most (all?) upload path handling goes through wp_upload_dir() that applies upload_dir filter to returned information. You should try filtering it for the duration of your code running and adjusting paths to wanted location.

share|improve this answer

Your Answer

 
discard

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.