图像大小验证(kb,mb等) [英] Image size validation (kb,mb etc.)

查看:100
本文介绍了图像大小验证(kb,mb等)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能给我模块以字节为单位验证图像大小...

Can anyone give me module for validating image size in bytes...

推荐答案

之前提过的类似问题: ^ ]

另外,请查看以下内容:如何在使用上传之前检查文件大小jQuery [ ^ ]
Similar question asked earlier: Can i validate size of an image in bytes using javascript[^]

Alernatively, look at these: How to check file size before uploading using jQuery[^]


[^ ]第一个链接..

I Googled[^] it and found this[^] first link..

var xhr = new XMLHttpRequest();
xhr.open('HEAD', 'img/test.jpg', true);
xhr.onreadystatechange = function(){
  if ( xhr.readyState == 4 ) {
    if ( xhr.status == 200 ) {
      alert('Size in bytes: ' + xhr.getResponseHeader('Content-Length'));
    } else {
      alert('ERROR');
    }
  }
};
xhr.send(null);


这篇关于图像大小验证(kb,mb等)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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