Your problem is here:
$file = fopen($_FILES['upload_csv']['tmp_name'], 'r');
$ext = pathinfo($file, PATHINFO_EXTENSION);
fopen
returns a file handle for use reading and writing a file, but pathinfo
is expecting a string containing a filename (optionally, with a path), but you're giving it a file handle.
You should, in any case, be looking at $_FILES['upload_csv']['name']
, which is the original name of the file, and extracting the file extension from that.