Is there any way to find the exact file type in php without looking for the letters after the dot(.) ?. Because in that case even if you rename a exe file as png, it will be considered as a png only which is malicious. And some PHP functions like pathinfo() also returns the value after dot only which is not reliable. Any suggestion or idea on this would be greatly appreciated.
Is there any way to find the exact file type in php without looking
Share
What you are looking for is not “the extension”, it’s the type of the file. This has been standardized as the MIME type. There are many ways to detect the MIME type of a file, all previously discussed. The preferred method to date is finfo.