public function upload($target = null, $append_sub_dirs = false)
    {
        if (!\function_exists('wp_handle_upload')) {
            require_once(ABSPATH . 'wp-admin/includes/file.php');
        }

        if ($target !== null) {
            $closure = function ($upload_dir) use ($target, $append_sub_dirs) {
                $upload_dir['subdir'] = '/' . \untrailingslashit($target);

                if ($append_sub_dirs !== false) {
                    $upload_dir['subdir'] = '/' . \untrailingslashit($target) . $upload_dir['subdir'];
                }

                $upload_dir['path'] = $upload_dir['basedir'] . $upload_dir['subdir'];
                $upload_dir['url'] = $upload_dir['baseurl'] . $upload_dir['subdir'];

                return $upload_dir;
            };

            \add_filter('upload_dir', $closure);
        }

        $data = $this->get_original_data();

        $result = \wp_handle_upload($data, ['test_form' => false]);

        if ($target !== null) {
            \remove_filter('upload_dir', $closure);
        }

        if (isset($result['file'])) {
            $this->upload_path = $result['file'];
            $this->upload_url = $result['url'];
            $this->upload_type = $result['type'];

            return true;
        }

        if (isset($result['error'])) {
            $this->upload_error = $result['error'];
        }

        return false;
    }