Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Determining filetype
- Schraalhans Keukenmeester
February 17, 2007, 7:15 pm
rate this thread
binary or ascii data other than by examining its extension? I can't find
a ready-made function or script online that does so.
If I open a file with less on my linux box for example it warns when it
'thinks' it's binary rather than ascii.
Re: Determining filetype
The "file" command on unix should tell you if the file is text or
You could also do it with a regexp:
$isBinary = preg_match('/[^\x08\t\n\r\f\x20-\x7e]/',
(By the way, less can be made to stop warning you by using the -f
option: less -f /usr/local/bin/php)