Return to Snippet

Revision: 61273
at December 3, 2012 20:39 by satinfo30


Initial Code
function validateFileSize(component,maxSize,msg){
		if(navigator.appName=="Microsoft Internet Explorer"){
			if(component.value){
				var myFSO 		= 	new ActiveXObject("Scripting.FileSystemObject");
				var filepath 	= 	component.value;
				var thefile 	= 	myFSO.getFile(filepath);
				var size 		= 	thefile.size;
			} 
		} else {
			if(component.files[0]!=''){
				size		=	component.files[0].size;
			} 
		}
		if(size!='' && size>maxSize){
			jAlert('Upload file size should be less than 25MB.','document.theform.uploadbroucher','uploadbroucher');
			document.getElementById('uploadbroucher').value="";
			return false;
		} else {
			return true;
		}
	}


component - document.getElementById('filed')

Initial URL
http://deepeshdarshan.wordpress.com/2012/06/20/how-to-validate-upload-file-size-and-file-extension-using-javascript/

Initial Description
Get file size from javascript code

Initial Title
file size from javascript

Initial Tags

                                

Initial Language
JavaScript