Use PHP's finfo for magic file checking, falling back on O/S's file binary executable. Move all file usage to Utility function.