Reply to Re: check for jpg and gif without Zend?

Your name:

Reply:


Posted by Andy Grayndler on 12/03/06 01:04

On Sat, 25 Nov 2006, Geoff wrote:

> Previously I was able to check for an uploaded file to be a jpg or a
> gif by using the exif_imagetype() function.
>
> I had to change from hosting provider and the new one doesn't want to
> enable Zend on their php.
>
> I would like to have a way to check for a file to be a jpg or gif file
> in another way.
>
> Is there anyone who can help me?

I think so, I ran into the same problem, only in a different direction, I
had not attempted to upload files using PHP until recently.

I was uploading an image file to a filesystem whilst also entering the
details of the upload into a database - these included FileName, FileSize
and FileType - these were taken from $_FILES['upload']['name'],
$_FILES['upload']['size'], $_FILES['upload']['type'] - GIF and JPG were
represented as image/gif and image/jpeg as the types I uploaded, so I used
the following:

$filetype = $_FILES['upload']['type'];

// upload was the name of the upload field in the previous form.

switch($filetype) {
case 'image/jpeg':
$extention = 'jpg';
break;

case 'image/gif':
$extention = 'gif';

//( the reason for the switch is that I had a lot more image formats to
sort through )

Sorry for the slightly longwinded answer - I was going mostly by memory.

Cheers!

Andy Grayndler
http://aphpkb.sf.net
andyg@atmail.com

[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

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