Extension was not detected correctly if the exif_imagetype function does not exists because was extracted ".jpg" instead of "jpg"
Now works correctly