留言板

AUI validation for image size

Mohammad Kalesha,修改在10 年前。

AUI validation for image size

New Member 帖子: 14 加入日期: 13-7-15 最近的帖子
Hi All,

How can i validate the image which has less than 40KB sizes only..

Thanks&Regards
thumbnail
Zeno Rocha,修改在10 年前。

RE: AUI validation for image size

New Member 帖子: 11 加入日期: 12-6-29 最近的帖子
AlloyUI doesn't have access to image size in bytes, only dimensions like width and height.
thumbnail
mohammad azaruddin,修改在9 年前。

RE: AUI validation for image size

Expert 帖子: 492 加入日期: 12-9-17 最近的帖子
Zeno Rocha:
AlloyUI doesn't have access to image size in bytes, only dimensions like width and height.



Hi how to validate dimensions like width and height in aui
Siraj Choudhary,修改在10 年前。

RE: AUI validation for image size

Junior Member 帖子: 31 加入日期: 13-11-13 最近的帖子
use javascript to get the size of a file, call this function onchange..and have one boolean flag as true ( var uploadSize=true ) in my code.. and write aui custom validator..
below is the code for file size validation..
var uploadSize=true;
   		 	
  		function setUploadSize(fileInput)
	  	{	
		      var size=0;
		      for(var num1=0;num1<fileinput.files.length;num1++) { var file="fileInput.files[num1];" if(file.size>5242880)
		        	{
		        	  document.getElementById('<portlet:namespace />copyUpload').focus();
		        	  uploadSize=false;
		        	}else{
		        		 uploadSize=true;
		        	}
			        size+=file.size;
			  }
	 	 }	

<aui:input name="copyUpload" type="file" label="Upload Scanned Property Card" helpmessage="Accept only Pdf Format" style="width:200px" onchange="setUploadSize(this)" id="copyUpload">
						<aui:validator name="custom" errormessage="File size should not be more than 5Mb">
							function(val,node,junction){
								if(uploadSize==true){
									return true;
								}else{
									return false;
								}
							}
						</aui:validator>
					</aui:input>
</fileinput.files.length;num1++)>



Siraj Choudhary
thumbnail
mohammad azaruddin,修改在9 年前。

RE: AUI validation for image size

Expert 帖子: 492 加入日期: 12-9-17 最近的帖子
Thanks emoticonemoticonemoticonemoticon