i am detecting images on my webpage with javascript document.images function which returns an rray of images. Is there any way to get the mime type of the image from this since i am not using any extension names on images which are loading?
For detecting MIME-types, use the aptly named "mimetype" command. It has a number of options for formatting the output, it even has an option for backward compatibility to "file". But most of all, it accepts input not only as file, but also via stdin/pipe, so you can avoid temporary files when processing streams.
Using JavaScript, you can easily check the selected file extension with allowed file extensions and can restrict the user to upload only the allowed file types. For this we will use fileValidation() function. We will create fileValidation() function that contains the complete file type validation code.
One of the most important pieces of data, called the MIME type specifies what the body of text describes. For instance, a GIF image is given the MIME type of image/gif, a JPEG image is image/jpg, and postscript is application/postscript.
I don't think this is possible, apart from requesting the image again in jQuery and trying to use a MIME type check on the data. (You might be able to send a HEAD request and get whatever Content-type was returned)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With