|
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]
|