javascript - How to get the file size of an image
三叔
三叔 2017-06-14 10:53:48
0
5
917
<img src="https://img.biaoqing.com/stuff/2017/1/23/356154f62cc144a38fec7028765210a0.gif">

How to get the file size of this picture

三叔
三叔

reply all(5)
代言
// 可以大致的知道图片的文件大小/精确大小需要获取responseHeaders的 content-length
$.ajax({
    url:'https://img.biaoqing.com/stuff/2017/1/23/356154f62cc144a38fec7028765210a0.gif',
    success: function(data){
        console.log(data.length)
    }
})
我想大声告诉你

Let the backend give it to you~ These are the static resources of the server

Ty80

Pass it to the background, just use size() in the background (in java)

扔个三星炸死你

After the pictures are loaded, can I just use JQ? If you want to know the image size before loading, there seems to be a new Image() or something?

$('#info').html($('img').eq(0).width()+' ' +$('img').eq(0).height());
Ty80

Put it in inupt and you can get it

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template