I'm trying to check the MIME type of an uploaded file in my PHP application. I upload the file, then do this, where $file is the path to my file:
$finfo = new finfo(FILEINFO_MIME);
$mimetype = $finfo->file($file);
In this situation, $mimetype is always an empty string. I've tested on several file types (.jpg, .doc, .txt, .pdf) and it's always empty. It's supposed to return something like "image/jpeg".
I was debugging and changed the first line so that the code snippet is now this:
$finfo = new finfo(FILEINFO_NONE);
$info = $finfo->file($file);
In this situation, when I uploaded a jpg, $info was this: JPEG image data, JFIF standard 1.02. So now I know it's getting to the file correctly, but passing in FILEINFO_MIME doesn't give me back the correct mime string.
This only happens on my staging server. On my local server, I get the correct mime type. Does anyone have any ideas why my staging server returns an empty string for mime type?