通过Javascript检测图像的mime类型 [英] Detect mime type of an image via Javascript

查看:147
本文介绍了通过Javascript检测图像的mime类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用javascript document.images功能在我的网页上检测图像,这会返回一连串的图像。有没有办法从这个获取图像的mime类型,因为我没有在正在加载的图像上使用任何扩展名?

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?

推荐答案

我不认为这是可能的,除了在jQuery中再次请求图像并尝试对数据使用MIME类型检查。 (您可能能够发送HEAD请求并获取返回的任何内容类型)

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)

这篇关于通过Javascript检测图像的mime类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆