Add filter for $uploads in wp_handle_upload
|Reported by:||iandunn||Owned by:|
|Component:||Media||Keywords:||needs-patch reporter-feedback close|
Right now there isn't any way for a plugin to set a custom directory for file uploads. I understand that in most cases they should be placed in the default directory, but there are circumstances where this isn't desirable. For instance, I'm building a custom post type for a client, and they have a separate application that it will integrate with. That application has to have the files in a specific directory structure which can't be changed.
The only thing needed to get around this is a filter on $uploads.
$filename = wp_unique_filename( $uploads['path'], $file['name'], $unique_filename_callback ); // unmodified, just here to show placement $uploads = apply_filters( 'wp_handle_upload_uploads', $uploads );