WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
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 Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
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
Submit Site
Forex Trading Online forex trading platform

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 : Be the 1st to grade this Code Example
Viewed : 4810
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 
 

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



Check if a file exists on a remote FTP server with PHP
Categories : PHP, FTP, Regexps
crop and resize image class using gd library function
Categories : PHP, PHP Classes, GD image library, Graphics
Show Source with Line Numbers
Categories : PHP, Regexps, Filesystem
Avoiding or Detecting high bit characters in a string. Useful when you want to create a valid RSS feed
Categories : PHP, Strings, Unicode, Regexps, Rich Site Summary (RSS)
ereg -- Regular expression match
Categories : PHP, PHP Functions, Regexps
A couple of functions that convert an IP address into its color code and not-color-code. Useful when viewing an apache log with a mysql result grouped by IP
Categories : PHP, Graphics, Databases
How to display any array in several rows and columns of a table. Not just in one column or in alternate rows. This example shows a nice color table generated with PHP, but can be used with any array values(e.g. Database)
Categories : Arrays, PHP, Miscellaneous, Beginner Guides, Graphics
BBCode Formatting String
Categories : PHP, HTML, Regexps, Arrays
PHP Round Clock - Must have Gif support to use this.
Categories : PHP, Date Time, Graphics
Create Thumbnails - resize an image - jpeg, jpg, gif, png to the specifed width and height in proportion without loosing out on pixcel quality.
Categories : PHP, GD image library, Graphics
Tag content retrieval from websites with preg_match
Categories : PHP, Regexps, Arrays, HTML and PHP
I need a trim function/regexp that will trim all " " from the ends of a string.
Categories : Regexps, PHP, Strings
webcam cam view image ispy browser independant
Categories : Graphics, HTML, HTML and PHP, PHP
Random Image Display
Categories : PHP, Filesystem, Graphics, HTML and PHP
PHP Email image generator - hide your email from bots - using the GD Library
Categories : PHP, Graphics, GD image library, Beginner Guides