WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : How to check if a file is of type gif or jpg?
Categories : PHP, Regexps, Graphics
Boaz Yahav
Date : Oct 10th 1999
Grade : 5 of 5 (graded 1 times)
Viewed : 9228
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Boaz Yahav
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

One way to go about this is to use a regular expression :

If $file is the name of your file do:

<?
echo eregi("\.(gif)$",$file)?"File is a gif\n":(eregi("\.(jpe?g)$",$file)?"File is a jpeg\n":"File is
neither gif nor jpeg\n");
?>

A second option is to use the getimagesize() function. It returns an array containing the
image size, image type, and some other stuff


berber



PHP Email image generator - hide your email from bots - using the GD Library
Categories : PHP, Graphics, GD image library, Beginner Guides
PHP Domain Availability Checker
Categories : PHP, Complete Programs, Regexps, HTTP, Sockets
Diffusion-Limited Aggregation visualization
Categories : PHP, Graphics, Algorithms, Math.
img_upload - array img_upload(string 'form field name', string 'image name', string 'destination'); Returns an array with 2 elements. Index 0 contains the string name of the image. Index 1 contains the string path to the image.
Categories : Graphics, PHP
How to create charts for php using Rchart
Categories : PHP, Java, JSP, Graphics, Charts and Graphs
Annual Bar Chart
Categories : Graphics, PHP, Charts and Graphs
This script is a contact form between users of a website (kinda like the PM function on the forums)
Categories : PHP, Databases, MySQL, Regexps
Random Image Display
Categories : PHP, Filesystem, Graphics, HTML and PHP
ereg -- Regular expression match
Categories : PHP, PHP Functions, Regexps
Create images on fly using GD-Image Lib
Categories : PHP, Graphics
This is a script that list all image files on a given directory, and displays the thumbnails nicely formated within an HTML table. It also make use of JavScript to open pop up windows when the users want to see the full photo.
Categories : Graphics, PHP, Complete Programs, Java Script
a simple pie-chart in php3 (with gd)
Categories : PHP, Graphics, GD image library, Charts and Graphs
Advanced Image WaterMarker
Categories : PHP, PHP Classes, GD image library, Graphics, Object Oriented
making links from text
Categories : PHP, Regexps, Email
Parse html (title :: meta)
Categories : PHP, HTML and PHP, Regexps