我通过模拟$_文件数组解决了这个问题:
$file_array = array(
            \'name\' => basename( $file_path ),
            \'type\' => $url_type,
            \'tmp_name\' => $file_path,
            \'error\' => 0,
            \'size\' => filesize( $file_path )
        );
 然后
$att_id = media_handle_sideload( $file_array, $post_id );
 就这么简单。。