Search code examples
phplinuxfilefile-uploadidentification

Using /usr/bin/file to determine file type?


I'm planning to use this system program /usr/bin/file to determine uploaded file content type and then act accordingly.

Is this a good idea or are there things I should watch out for? (Or use something altogether different)


Solution

  • PHP has the fileinfo extension, which uses the same mechanism but is native to PHP.