Use iframe to upload pictures, detect picture size:
http://perfectlife.iteye.com/blog/396959
The following JS, compatibility issues, can not be achieved:
function Checkform (obj) {
Str=obj.value.tolowercase ();
var ext=str.split (".");
var type=filetype.split (",");
for (Var i=0;i<type.length;i++) {
Alert (ext[1]+ "," +type[i]);
if (Ext[1]==type[i]) {
Bool=true;
alert (bool);
}
}
if (bool) {
var boolsize=checksize (str);
alert (boolsize);
if (Boolsize==false) {
Alert ("You upload a picture too large to exceed" +filesize+ "KB");
return false;
}
}else{
Bool=false;
Alert ("The type you upload is not one of the" +type+ ");
return false;
}
}
function Checksize (fileName) {
var img=new Image ();
IMG.SRC=STR;
fsize=img.filesize/1024;
Fsize=fsize.tofixed (1);
alert (fsize);
if (img.readystate!= "complete") {
Bool=false;
return false;
}else{
Alert (fsize+ "," +filesize);
if (fsize>filesize) {
Bool=false;
return false;
}else{
Bool=false;
return true;
}
}
}
var imgsize = 1024 * 100; Max 100K
var temp = false;
function Checkimgsize (obj) {
if (Obj.value!= "") {
Detection type
var val = obj.value;
if (/^.*?\. ( Gif|png|jpg|jpeg|bmp) $/.test (val)) {
}else{
Alert ("Only upload images in gif, PNG, JPG, BMP format");
temp = false;
return false;
}
var img = new Image ();
Img.onreadystatechange = function () {
if (img.readystate = = "complete") {
if (img.filesize <=0 | | img.filesize > Imgsize) {
Alert ("Current file size" + img.filesize/1024 + "KB, exceeding maximum limit" + imgsize/1024 + "KB");
temp = false;
return false;
}else{
temp = true;
return true;
}
}
}
Img.src = val;
}
-----to be inspected, only temporarily stored, please do not copy