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
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
Mobile Dev World

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 : PHP Image Validation Class - test if a specific file is of a certain image type without relying on the said file extension.
Categories : PHP, PHP Classes, Data Validation, Graphics, Beginner Guides Click here to Update Your Picture
Alix Axel
Date : Apr 28th 2009
Grade : 3 of 5 (graded 2 times)
Viewed : 2211
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Alix Axel
Action : Grade This Code Example
Tools : My Examples List

 
Like this code?
Show the author your appreciation.
Submit your own code examples 
 

<?php

class Is_Image
{
    function
GIF($path)
    {
        if (
image_type_to_extension(intval(@exif_imagetype($path)), false) != 'gif')
        {
            return
false;
        }

        return
true;
    }

    function
JPG($path)
    {
        if (
image_type_to_extension(intval(@exif_imagetype($path)), false) != 'jpeg')
        {
            return
false;
        }

        return
true;
    }

    function
PNG($path)
    {
        if (
image_type_to_extension(intval(@exif_imagetype($path)), false) != 'png')
        {
            return
false;
        }

        return
true;
    }
}
?>




Usage:
<?php
var_dump
(Is_Image::GIF('path/to/file.gif'));
var_dump(Is_Image::JPG('path/to/file.jpg'));
var_dump(Is_Image::PNG('path/to/file.png'));
?>



Db_lib - practical example usage of database abstraction and form validation.
Categories : PHP, Form Processing, PHP Classes, Data Validation, Beginner Guides
Validator - A PHP class that can can be used for validating Email IDs and Dates
Categories : PHP, PHP Classes, Data Validation, Email, Date Time
A beginner's session handling class
Categories : PHP, PHP Classes, Sessions, Beginner Guides
PHP Email image generator - hide your email from bots - using the GD Library
Categories : PHP, Graphics, GD image library, Beginner Guides
A class to draw real 3D graphics with surface area
Categories : Graphics, PHP, PHP Classes
Three Cool Classes and One Trick
Categories : PHP, PHP Classes, Graphics, Email
PHP interface class to the eBusiness Charts generatation remote service.
Categories : PHP, PHP Classes, Graphics, Charts and Graphs
Advanced Image WaterMarker
Categories : PHP, PHP Classes, GD image library, Graphics, Object Oriented
Image Generation Class ( PNG Format )
Categories : PHP, GD image library, PHP Classes, Graphics
EasyPhpThumbnail Class - The EasyPhpThumbnail class allows you to generate thumbnails and handle image manipulation for GIF, JPG and PNG on-the-fly.
Categories : PHP, PHP Classes, Object Oriented, Graphics, GD image library
Banknote Validation - A PHP class that provides several methods to quickly validate banknote serial numbers of the following currencies: AUD, CAD, CHF, CNY, EUR, GBP, JPY, USD.
Categories : PHP, PHP Classes, Data Validation, Regexps
Find the day of the week for any given year/month/day.
Categories : PHP, Date Time, Data Validation, Algorithms, Beginner Guides
Simple image counter
Categories : PHP, Graphics, Filesystem, Beginner Guides
Ensure that a specific value lies within a specific range.
Categories : PHP, Beginner Guides, Data Validation
Find if a year is leap.
Categories : PHP, Date Time, Beginner Guides, Data Validation