That error is very probabbly due to incorrect loading of the required files from wp-admin; note how in your code those files are loaded only when a scpecific input has data (input_13
) but not in every case you need those files.
You do this:
if( !empty($_FILES['input_13']['name'])) {
require_once(ABSPATH . 'wp-admin/includes/file.php');
require_once(ABSPATH . 'wp-admin/includes/image.php');
// ....
}
So, if $_FILES['input_13']['name']
is empty, the rest of code that needs those files from wp-admin will fail.
Try to include the required files with a more appropiate logic.