php - Does file type relies on file extension? -
the file type relies on file extension? mean php's finfo analyze file data detemine file type or relies on file extension? change of .png file extension .txt not affect change of file type niether finfo nor email mime data attachment? googled , found nothing. please advice.
thanks,
php's fileinfo functions use local copy of libmagic. can @ php source code under "ext/fileinfo/" , see folder called libmagic. unix command "file" uses libmagic, running "file myfile.txt" should produce same output php function finfo_file().
https://en.wikipedia.org/wiki/file_%28command%29
libmagic examines portion of file, first few bytes , not rely on extension.
file's position-sensitive tests implemented matching various locations within file against textual database of magic numbers (see usage section). differs other simpler methods such file extensions , schemes mime.
Comments
Post a Comment