473,385 Members | 1,342 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

check for jpg and gif without Zend?

Hi

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?

Best regards,

Geoff

Nov 25 '06 #1
2 1834
<comp.lang.php>
<Geoff>
<25 Nov 2006 09:54:57 -0800>
<11**********************@h54g2000cwb.googlegroups .com>
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.
<?php

$logo="demo/whatever.jpg";

$logosize=getimagesize($logo);

print $logosize[2];

?>
$logosize[2];

If it prints a 2 then its a .jpg file - cant remember what 0 , 1 , 3 ,
etc stand for .
[0] is the width
[1] is the height
[2] is the image type
[3] is the width and height
<img src="<?php print $logo; ?>" width="<?php print $logosize[0]; ?>"
height="<?php print $logosize[1]; ?>" border="0" alt="">

As your grabbing the image info anyway - its usually a good idea to use
the width and height stuff as it saves the webpage from jumping all over
the place .
--
www.phpwhois.co.uk
Nov 25 '06 #2
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
an***@atmail.com

Dec 3 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Google alias | last post by:
My trial period for Zend studio has just ended, I've requested a personal licence, and got it. After I've entered and rebooted by computer I still get a popup saying "Licence expired!" everytime I...
27
by: mrbog | last post by:
Tell me if my assertion is wrong here: The only way to prevent session hijacking is to NEVER store authentication information (such as name/password) in the session. Well, to never authenticate...
8
by: Andy Jacobs | last post by:
Evening folks This has probably been asked before so apologies for that. I'm using Dreamweaver for PHP and have been for nearly a year. I've done some stuff that I'm very happy with but I'm...
0
by: cantelow | last post by:
Greetings. I am getting some Arithmetic Exception exit signal messages in my apache logs and intermittent lost pages in a photopost app, dating from an upgrade to php 4.3.10, and I'm...
3
by: nntp | last post by:
What is ZEND. Why it has anything to do with programming PHP?
1
by: Xristos Nikolopoulos | last post by:
Hello, I have made an application that needs to upload files, the application is deployed in several folders, and each folder has its php files. The problem is, I have in the folder I want to...
0
by: JoeT | last post by:
Hi... OK...I'm having difficulty understanding a problem with installing Zend Studio 5.5 on an Intel Mac. Prior to the install, I had the zend /library installed, and was able to...
0
by: corretge | last post by:
Zend outsourced the news service to businesses. NET ...
7
by: Service4PC | last post by:
Hi all, I've a problem... I'm writing an extension for php, and i need to execute a file php... but only the content of the file and not the file... Now I better explain: - the extension get the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.