About JS get upload file size processing principle is to use JS to read the current picture, and then create a new image and then the size of the picture read out, and then determine the current file picture size is not a specified size on OK.
<script language= "Web Effects" > function showsize (Files) { var fso,f; Fso=new ActiveXObject ("Scripting.FileSystemObject"); F=fso.getfile (files); var filesize = f.size; if ((filesize/1024) < 1024) { Alert (filesize/1024+ "K"); }else if ((filesize/1024) > 1024) && ((filesize/(1024*1024)) < 1024)) { Alert (filesize/(1024*1024) + "M"); }else{ Alert (filesize/(1024*1024*1024) + "G") } } </script>
Method Two : <input type= "Text" size= "4" value= "" Name= "Filesizelimit" id= "Filesizelimit"/> k <input type = "File" name= "File1" id= "file1" size= "" Onchange= "Changesrc" (This)/> <img src= "About:blank" Filechecker "alt=" test " height="/>
<script type= "Text/javascript" var ofilechecker = document.getElementById ("Filechecker");
Function changesrc (filepicker) { ofilechecker.src = Filepicker.value; }
Ofilechecker.onreadystatechange = function () { if ( Ofilechecker.readystate = = "complete") { Checksize (); } }
function checksize () { var limit = document.getElementById ("Filesizelimit"). Value * 1024;
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.