Currently I am using
if(navigator.appName=='Microsoft Internet Explorer'){
if(component.value){
var oas = new ActiveXObject("Scripting.FileSystemObject");
var e = oas.getFile(component.value);
var size = e.size;
}
}
to validate the file size.
Is there any other way to validate the size
Automation server can't create object error is displayed
I know it has something to do with Enabling ActiveX Controls in Settings, but thats not going to happen because one cant control client side system and IE7/8 doesnot even support file Api
IE doesn't support this feature
I had found a great plugin for file upload jQuery-File-Upload
Only IE 9 is not Supporting this Feature.
All Other IE Versions >9 have no Issues.
You can Resolve your issue By applying filter for IE 9 and get file size. use Below code in else condition for other browsers as per Below.
if (browserInfo.indexOf("msie") > -1)
{
/* IE */
var filepath = document.getElementById('idControl').value;
if(browserInfo.indexOf("msie 9") == -1)
{
var myFSO = new ActiveXObject("Scripting.FileSystemObject");
if (filepath == "") {
alert("Please Select File");
$("#selectorID").attr("src", $("#Contenturlprifix").val() + "/content/img/NoPhoto.png");
return false;
}
file = myFSO.getFile(filepath);
filetype = document.getElementById('idControl').accept
}
} else {
/* Other */
file = document.getElementById('idControl').files[0];
if (file == undefined) {
alert("Please Select File");
return false;
}
else {
filetype = file.type;
}
}
if (file != undefined) {
//10mb size
if (file.size / 1024 > 10240) {
alert("size Exists");
return false;
}
else if (filetype.indexOf('image/') == -1) {
alert("Select only images");
return false;
}
}
TRY THIS............
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.