Is it necessary to copy the "finfo" class code into the main PHP file or create a separate file for it?

It is not necessary to copy the "finfo" class code into the main PHP file. It is best practice to create a separate file for the "finfo" class code and then include or require that file in the main PHP file where it is needed.

// finfo_class.php
class finfo {
    // Class code here
}

// main.php
require_once('finfo_class.php');

// Rest of the code here