You are here: Re: mime types « All PHP « IT news, forums, messages
Re: mime types

Posted by Norman Peelman on 02/20/07 04:39

bill wrote:
> Can anyone help. I am using the following code to check that jpg image
> only can be uploaded
>
> if ($_FILES['userfile']['type'] != 'image/jpeg')
> {
> $msg = 'Problem: file is not jpg';
> }
>
> when uploading a jpg or jpeg this works fine in firefox but when i try
> to upload a jpg using internet explorer an error is produced saying that
> it is not a jpg when in fact it is.
> Can anyone help
> Thanks
> bill

Try:

if (($_FILES['userfile']['type'] != 'image/jpeg') &&
($_FILES['userfile']['type'] != 'image/jpg'))
{
$msg = 'Problem: file is not jpg';
}

or:

//edit array to suit needs
$img_types = array('image/jpeg','image_jpg','image/gif','image/png');
if (!in_array($_FILES['userfile']['type'],$allowed_types))
{
$msg = 'Problem: file is not of allowed image type.';
}

---
Norm

 

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

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