Skip to content
This repository was archived by the owner on May 25, 2023. It is now read-only.

Commit f8692e7

Browse files
committed
Merge pull request #2788 from exussum12/exif_imagetype
Use Exif Data to check the image type, Do not rely on extention
2 parents fb2c280 + 54c055c commit f8692e7

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

server/php/UploadHandler.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,25 @@ protected function gd_create_scaled_image($file_name, $version, $options) {
613613
}
614614
list($file_path, $new_file_path) =
615615
$this->get_scaled_image_file_paths($file_name, $version);
616-
$type = strtolower(substr(strrchr($file_name, '.'), 1));
616+
if (function_exists('exif_imagetype')) {
617+
//use the signature of the file
618+
switch(exif_imagetype($file_path)){
619+
case IMAGETYPE_JPEG:
620+
$type = 'jpg';
621+
break;
622+
case IMAGETYPE_PNG:
623+
$type = 'png';
624+
break;
625+
case IMAGETYPE_GIF:
626+
$type = 'gif';
627+
break;
628+
default:
629+
$type = '';
630+
}
631+
}else {
632+
//use the extention;
633+
$type = strtolower(substr(strrchr($file_name, '.'), 1));
634+
}
617635
switch ($type) {
618636
case 'jpg':
619637
case 'jpeg':

0 commit comments

Comments
 (0)