Questions tagged «image-size»

8
使用Javascript上传之前检查图像的宽度和高度
我有一个JPS,其中用户可以在其中放置图像: <div class="photo"> <div>Photo (max 240x240 and 100 kb):</div> <input type="file" name="photo" id="photoInput" onchange="checkPhoto(this)"/> </div> 我写了这个js: function checkPhoto(target) { if(target.files[0].type.indexOf("image") == -1) { document.getElementById("photoLabel").innerHTML = "File not supported"; return false; } if(target.files[0].size > 102400) { document.getElementById("photoLabel").innerHTML = "Image too big (max 100kb)"; return false; } document.getElementById("photoLabel").innerHTML = ""; return true; …

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.