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
Forex Trading Online forex trading platform
Get Mime-Type for image-type returned by getimagesize, exif_read_data, exif_thumbnail, exif_imagetype

image_type_to_mime_type

(PHP 4 >= 4.3.0, PHP 5)

image_type_to_mime_typeGet Mime-Type for image-type returned by getimagesize, exif_read_data, exif_thumbnail, exif_imagetype

Description

string image_type_to_mime_type ( int $imagetype )

The image_type_to_mime_type() function will determine the Mime-Type for an IMAGETYPE constant.

Parameters

imagetype

One of the IMAGETYPE_XXX constants.

Return Values

The returned values are as follows

Returned values Constants
imagetype Returned value
IMAGETYPE_GIF image/gif
IMAGETYPE_JPEG image/jpeg
IMAGETYPE_PNG image/png
IMAGETYPE_SWF application/x-shockwave-flash
IMAGETYPE_PSD image/psd
IMAGETYPE_BMP image/bmp
IMAGETYPE_TIFF_II (intel byte order) image/tiff
IMAGETYPE_TIFF_MM (motorola byte order) image/tiff
IMAGETYPE_JPC application/octet-stream
IMAGETYPE_JP2 image/jp2
IMAGETYPE_JPX application/octet-stream
IMAGETYPE_JB2 application/octet-stream
IMAGETYPE_SWC application/x-shockwave-flash
IMAGETYPE_IFF image/iff
IMAGETYPE_WBMP image/vnd.wap.wbmp
IMAGETYPE_XBM image/xbm
IMAGETYPE_ICO image/vnd.microsoft.icon

Examples

Example #1 image_type_to_mime_type() example

<?php
header
("Content-type: " image_type_to_mime_type(IMAGETYPE_PNG));
?>

Notes

Note: This function does not require the GD image library.

See Also


is there an option to alter the default MIME-Type for a particular folder only?
Categories : Apache, Web Servers
How to know which input button of type image was pressed in a form with multiple image buttons (_x and _y) in PHP?
Categories : PHP, Variables, HTML
Check to see whether the type of file the user uploaded is a valid image type to upload.
Categories : PHP



how to make an image reset a form (instead of using the conventional reset button type).
Categories : Java Script
This class allows you to upload files using your broswer. It checks file type, image type, file size, image height and width, and more.
Categories : PHP, PHP Classes
Get the correct extension and MIME types of an image, even when the filename is incorrect.
Categories : PHP, Filesystem, General SQL
Browser Detection, Redirection Type, MSIE, MOZILLA, Netscape Navigator, NS, $HTTP_USER_AGENT, HTTP_USER_AGENT
Categories : PHP, HTTP, Browsers, HTML and PHP
Building a basic error handler with custom error types
Categories : PHP, PHP Classes, Errors and Logging
Validate an image type using pathinfo() Function
Categories : PHP, Filesystem
Solution to those 'tell-a-friend' type email issues
Categories : PHP, Email, Databases, MySQL
Is it possible to declare C type anon arrays in PHP like int months[] = {0, 1, 2, 3}; ?
Categories : Arrays, PHP
Directory cleanup - This script was created for those times when you've allowed a directory to be overloaded with temp or cache type files which all need to be deleted.
Categories : PHP, Filesystem
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
This program implements hot link prevention in php. It is useful for webmasters who do not have access to the server at a level where they can control hot linking can still supply some type of hot link prevention for thier site by using php.
Categories : PHP, Filesystem, Graphics, Content Management