How to add CSV upload functionality on the edit page of a Custom Post Type

So, I am creating a school website based on WordPress. In that, I need to show birthdays of students on the front page. I've created a Custom Post Type named Birthdays which will contain the list of all the students and their birthdays.

I need to upload the details of students like, student name, date of birth, class, etc. in bulk using a CSV file. How do I accomplish this.

I've tried used this code to show an upload button in the backend:

    /**
 * Show 'insert posts' button on backend
 */
add_action( admin_notices, function() {
    echo div class='updated';
    echo p;
    echo Upload the birthdays using CSV.;
    echo form method='POST' action='{$_SERVER[REQUEST_URI]}insert_birthdays';
    echo input style='margin:0.25em 1em' type='file' name='csv_file';
    echo input class='button button-primary' type='submit' value='Upload';
    echo /form;
    echo /p;
    echo /div;
});

It shows like this:

How do I add this functionality? Or if there's a better approach to it? Please suggest.

Regards

Topic uploads csv dashboard bulk-import Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.