473,545 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1849
<comp.lang.ph p>
<Geoff>
<25 Nov 2006 09:54:57 -0800>
<11************ **********@h54g 2000cwb.googleg roups.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=getim agesize($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($filetyp e) {
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.co m

Dec 3 '06 #3

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

Similar topics

2
3657
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 request a php-page from localhost. Very annoying! If googled on on licence expired zend studion personal edition. But that gave me mostely...
27
7091
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 a user from information you got from the session. Each secure app on a site must challenge the user for name and password, each and every time the...
8
779
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 getting to the stage where it doesn't go far enough. I want something that will still automate a lot of what I do rather than having to hand code...
0
1453
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 investigating whether this could have anything to do with the Zend incompatability that is mentioned in red on php.net for the 4.3.10 download. php 4.3.10...
3
2239
by: nntp | last post by:
What is ZEND. Why it has anything to do with programming PHP?
1
2140
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 upload the php files that do the job and a php.ini file to change limits.
0
2054
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 successfully run Zend_Db commands against a local mysql server (5.1) from the commandline (e.g. php testdb.php). This stuff ran just fine. The code is simply:
0
1317
by: corretge | last post by:
Zend outsourced the news service to businesses. NET http://66.102.9.104/translate_c?hl=ca&sl=ca&tl=en&u=http://bloc.corretge.cat/2008/10/zend-subcontracta-newsletter-empreses.html&usg=ALkJrhjkf9b8JtrGNpx994AAqE7mztkn7Q It seems that Zend, the creator of the PHP core current and known as The PHP Company, not too well coordinated marketing...
7
3523
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 file content of a php file (php code and html code mixed..) - execute the content with some zend api function I've already tried with...
0
7468
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7401
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7808
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4945
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3450
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1884
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
704
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.