I am getting an error while using finfo and file_mime_type. Can you help me resolve it?
I am checking the file mime type before storing the file name in database. I have defined allowed mime types as '''' $allowedMIMETypes = ['image/jpeg' => 'jpeg', 'image/jpg' => 'jpg', 'image/png' => 'png']; ''''
Then I write
''''
$finfo = new finfo(FILEINFO_MIME_TYPE);
$tmpFile = $_FILES['photo-file']['tmp_name'];
$actualMIMEType = $finfo->file($tmpFile);
if(!isset($allowedMIMETypes[$actualMIMEType])
{
throw new Exception('file type is not supported');
}
$fileExtension = $allowedMIMETypes[$actualMIMEType];
''''
I get $fileExtension as jpeg while my photo file is a jpg.
These are the two warnings I get
''''
Warning: move_uploaded_file(/home2/padmaf64/public_html/pmps-admin/pmps-achievers/studentPhoto_22ca8364f05f9af4b08ab84ce49f24a4.jpeg): Failed to open stream: No such file or directory in /home2/padmaf64/public_html/pmps-admin/pmps-addAchiever.php on line 64
Warning: move_uploaded_file(): Unable to move "/tmp/phps8jvj09ccme512QgD61" to "/home2/padmaf64/public_html/pmps-admin/pmps-achievers/studentPhoto_22ca8364f05f9af4b08ab84ce49f24a4.jpeg" in /home2/padmaf64/public_html/pmps-admin/pmps-addAchiever.php on line 64
''''
Can anyone help me solve this? Many thanks to you in advance. I hope my question is acceptable. Thanks again.