Reply to Re: Determining filetype

Your name:

Reply:


Posted by petersprc on 02/17/07 20:01

Hi,

The "file" command on unix should tell you if the file is text or
binary.

You could also do it with a regexp:

$isBinary = preg_match('/[^\x08\t\n\r\f\x20-\x7e]/',
file_get_contents('/the/file'));

(By the way, less can be made to stop warning you by using the -f
option: less -f /usr/local/bin/php)

On Feb 17, 2:15 pm, Schraalhans Keukenmeester <bitbuc...@invalid.spam>
wrote:
> Is it possible in PHP to determine whether a file is (intended as)
> 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.
>
> TIA.
> Sh.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация