Function Checkfiles (obj) {
var array = new Array (' GIF ', ' jpeg ', ' png ', ' jpg '),////file type that can be uploaded
if (Obj.value = = " {
Alert ("Let's Select a picture to upload!");
return false;
}
Else {
var filecontenttype = Obj.value.match (/^ (. *) (\) (. {1,8}) $/) [3]; This file type is useful:)
var isexists = false;
//$ ("#img"). attr ("src", obj.value)
var fileInput = $ ("#logo") [0];
B Ytesize = fileinput.files[0].size;
//var size = Math.ceil (bytesize/1024);/* Used to determine the size of the image */
//var twidthheight = Testwidthheight (fileInput);
for (v Ar i in array) {
if (filecontenttype.tolowercase () = = Array[i].tolowercase ()) {
Isexists = true;
}
}
if (isexists = = False) {
Obj.value = null;
Alert ("The Upload picture type is incorrect!");
return false;
}
/* Determine if the size of the picture is qualified */
Testwidthheight (fileInput, obj);
}
}
function testwidthheight (file, obj) {
var isallow = false;
var max_width = "291";
var max_height = "77";
if (File.files && file.files[0]) {
var fileData = file.files[0];
Reading picture data
var reader = new FileReader ();
Reader.onload = function (e) {
var data = E.target.result;
Load picture to get the true width and height of the picture
var image = new Image ();
Image.onload = function () {
var width = image.width;
var height = image.height;
Isallow = width >= max_width && height >= max_height;
Console.log (width >= max_width);
Console.log (height >= max_height);
PD (Isallow, obj);
};
IMAGE.SRC = data;
};
Reader.readasdataurl (FileData);
} else {
//ie use filters to handle picture size control
//file name in IE is the full picture local path
var input = $ ("#logo") [0];
//var input = UPLOADER.G ET (' target '). All (' input '). Getdomnode ();
Input.select ();
//Ensure that IE9 does not occur because of a security issue that prevents Access
Input.blur ();
var src = document.selection.createRange (). text;
var img = $ (' & Lt;img style= "Filter:progid:DXImageTransform.Microsoft.AlphaImageLoader (sizingmethod=image); width:300px; Visibility:hidden, "/>"). AppendTo (' body '). Getdomnode ();
Img.filters.item (' DXImageTransform.Microsoft.AlphaImageLoader '). src = src;
var width = img.offsetwidth;
var height = img.offsetheight;
$ (IMG). Remove ();
Isallow = width >= max_width && height >= max_height;
PD (Isallow, obj);
}
}
var tishi=$ ("#tishi");
function PD (o, obj) {
if (o) {
Obj.value = null;
$ ("#tishi"). Text ("The picture exceeds the limit size upload failed");
$ ("#tishi"). CSS ("Color", "red");
} else {
Console.log ("0000");
$ ("#tishi"). Text ("Upload succeeded");
$ ("#tishi"). CSS ("Color", "green");
}
}
Input type= ' file ' upload file to determine whether the size of the picture is qualified with WITDH and height