Home » Tag Archives: mime full form

Tag Archives: mime full form

Advanced method to check the mime type of file in php

Usually code is if ($_FILES['input_field_name']['type'] == 'image/jpeg') { //some code } but it is not fully validating the file types(mime). The following code will output the correct file type and avoids the security vulnerabilities of php. $phpfileInfo = new finfo(FILEINFO_MIME_TYPE); $PhpfileContents = file_get_contents($_FILES['name_of_input_field']['tmp_name']); $MimeFileType = $phpfileInfo->buffer(PhpfileContents);

Read More »