You are here: Re: Uploads and mime type « PHP Programming Language « IT news, forums, messages
Re: Uploads and mime type

Posted by Rik Wasmus on 11/15/07 23:17

On Thu, 15 Nov 2007 22:59:03 +0100, Mad Hatter <colin@class31.co.uk> wrote:

> Hi folks
>
> I'm a bit confused with an upload script that I've written. I want to be
> able to check the file type of an upload by checking the mime type but
> I'm
> not getting the results that I thought I should. According to what I've
> read .zip files should return something like 'application/zip' or
> 'application/x-zip-compressed', RAR should return
> 'application/x-rar-compressed' but both return
> 'application/octet-stream'.
> I'm getting the results that I expected when checking .jpg, .png of .gif
> files.
>
> I'm checking the mime type using $_FILES['userfile']['type']

The mime-type is user-submitted, totally unreliable and shouldn't be
trusted for any further processing. application/octet-stream is usually
the fallback for a binary file for which the the UA either doesn't know or
doesn't care about the mime-type.

If the mime-type is really important to you, try the fileinfo function
(http://nl2.php.net/manual/en/ref.fileinfo.php).

What's the reason the mime-type is of importance to you?
--
Rik Wasmus

 

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

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