3
我在下面的代碼中嘗試從實際URL獲取圖片大小(以KB/MB/GB爲單位)。但它不起作用。如何從網址獲取圖片大小
var xhr = new XMLHttpRequest();
xhr.open('HEAD', 'http://www.2015autoblog.com/wp-content/uploads/2014/09/2015-Toyota-Land-Cruiser-Front.jpg', true);
調試
alert(xhr.status);
if (xhr.status == 200) {
alert('Size in bytes: ' + xhr.getResponseHeader('Content-Length'));
} else {
alert('ERROR');
}
不是高度和寬度。我需要KB/MB的大小。如1 MB等 – 2014-10-17 08:00:48
您是否找到任何解決方案? – 2017-09-07 13:17:54