Upload files to the plugin menu

I think I’ve been down that road. Take a look at wp_handle_upload, which will upload your file to the /uploads directory and then wp_insert_attachment and wp_generate_attachment_metadata to list said upload in the media library as an attachment which will ‘register it in the wordpress database’. Then you can query attachments like this:

$attachments = get_posts( array( 'post_type' => 'attachment') );