I wrote a plugin that accepts files via Wordpress and saves them outside of the server. Now I would like to save the metadata as normal in Wordpress, as if the file were on the server. Is there a hook for this that calls wp_insert_attachment or do I have to do it manually using the $wpdb variable? When I try to include /var/www/html/wp-admin/includes/file.php with require_once, I get a lot of errors and can not access wp_ functions.
I am grateful for any help