Question

I am developing app using cakephp 2.4 in windows in which I need to create Image upload facility. But when I use exif_imagetype it gives me fatal-error. So using this code I checked if exif tool is installed or not

if (function_exists('exif_imagetype')) {
echo "This function is installed";
} else {
echo "It is not";
}

And its showing that exif tool is not installed. But in php.ini I can see this part

;extension=php_bz2.dll
;extension=php_curl.dll
;extension=php_dba.dll
extension=php_mbstring.dll
;extension=php_exif.dll
;extension=php_fileinfo.dll
extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_intl.dll
;extension=php_imap.dll

I am not sure what is wrong. Can anybody help me to solve this. My php version is 5.4.3 and I am using wampserver

Was it helpful?

Solution

EXIF extension is a standard part of PHP distributions, but it must be enabled in php.ini file in order to use its functions. On windows, EXIF extension also depends on mbstring, an extension that provides multi-byte string parsing. Moreover, the sequence of enabling extensions in php.ini file does matter. If exif is enabled prior to mbstring, EXIF functions will not be available at run-time.

mbstring extension must be enabled before EXIF!

which is enabled in your case but php_exif.dll is not.

If you need to use EXIF functions in your environment, be it development or production, this is something you need to keep in mind. By default, extensions are ordered in alphabetical order in php.ini file. This makes it very easy to run into situation when you start banging your head against the wall as you don’t realize why function_exists('exif_imagetype') keeps returning FALSE even though you have enabled both EXIF and mbstring extensions.

Remove the comment ; and enable EXIF function

OTHER TIPS

Remove the semicolon (;)

Before:

;extension=php_exif.dll

After:

extension=php_exif.dll

Save the php.ini and then restart wampserver

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top