<form enctype="multipart/form-data" name="form1"> <input type="file" name="file"> <input type="button" value="取得图片的大小" onClick="getSize()"> </form> <img name="pic" alt="在这儿显示图片">function getSize(){ size = 0; imgURL = form1.file.value; imgURLsplice = imgURL.split("\\").pop(); imgURLsplicelocal ="../assets/img/" + imgURLsplice; img = new Image(); img.src = imgURLsplicelocal; pic.src = imgURLsplicelocal; if (size <= 0){ size = img.fileSize / 1024; } alert("图片大小为:" + size + "KB"); }
添加回答
举报
0/150
提交
取消