Changing upload directory for plugin uploads only

There must be something identifiable about your form data, such as your input names. Check for one or more of those and process accordingly.

function custom_upload_dir($args) {   
    if (isset($_POST['something'])) {
        $args['path'] = $args['basedir'] . "/mypath" . $args['subdir'];
        $args['url'] = $args['baseurl'] . "/mypath" . $args['subdir'];
    }
    return $args;
}

After some investigation, the only things I see that might help are …

  1. The post ID is passed through the POST data to the callback.
    However I don’t know this would be set to in you custom plugin page.
  2. $_SERVER['HTTP_REFERER'] appears to be set correctly. You could
    parse that to determine if your plugin page is the originating
    page.

If I had the full plugin source I could do some testing.

Leave a Comment