Our project has an image uploading module using Java. While uploading image, if a user uploads an image with an extension of jpg/jpeg/gif/png etc., whatever the extension, we save it with same extension by changing just its name.
But here is one small issue. Suppose the user removes the extension of that image manually (of course it never happens, but let's consider it as example) and uploaded the file, it doesn't have any extension.
Is there any way to find out extension/format after reading that image (like after reading the image using getBufferedImage()
)?
Here I can't use mimeType
as we are taking mime type from user while uploading image itself. The user may upload image without an extension, by selecting the mimeType
as "image/jpeg"
.