You are here: Re: How reliable is mime type in $_FILES superglobal. « PHP Programming Language « IT news, forums, messages
Re: How reliable is mime type in $_FILES superglobal.

Posted by d on 01/31/06 12:18

"NC" <nc@iname.com> wrote in message
news:1138657877.599655.215680@g47g2000cwa.googlegroups.com...
> splodge wrote:
>>
>> I am working on a portal, part of which allows users to upload files.
>> Part of the array within $_FILES superglobal gives the mime type for the
>> file. Is this 100% reliable / accurate? If the mime type says the file
>> type is jpeg is it always right?
>
> It depends on your definition of "right"... If I understand correctly,
> MIME type is determined based on the file's extension.

Nope - PHP uses the MIME Magic library to determine the mime type of a file
based on the position of key bytes within the file:

http://uk2.php.net/mime_magic

So you could call an .exe .txt, and it would be picked up as an executable.

> Cheers,
> NC
>

 

Navigation:

[Reply to this 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

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