Nonsense not to say, directly to everyone paste JS implementation Click the image to display the original picture code, the specific code as follows:
function DrawImage (IMGD) {
var image = new Image ();
IMAGE.SRC=IMGD.SRC;
var width = $ (IMGD). attr ("width");
var height = $ (IMGD). attr ("height");
if (width >100 && height>80) {
imgd.width=100;
imgd.height=80;
imgd.alt=image.width+ "x" +image.height;
} else{
if (image.width>0 && image.height>0) {
flag=true;
if (image.width>300 | | image.height>200) {
imgd.width=image.width/2;
IMGD.HEIGHT=IMAGE.HEIGHT/2;
imgd.alt=image.width+ "x" +image.height;
} else{
imgd.width=image.width;
Imgd.height=image.height;
imgd.alt=image.width+ "x" +image.height
}}
}
Below share a paragraph about JS upload picture in time to preview
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">