不需要知道图片的长度也可以上传图片的!在显示图片时给出图片的长和宽,图片会按实现的长宽显示!

解决方案 »

  1.   

    少写一个字,重发!
    不需要知道图片的长度也可以上传图片的!在显示图片时不给出图片的长和宽,图片会按实现的长宽显示!
      

  2.   

    我就是想要知道他的长和宽,因为如果用原始的尺寸可能会把页面撑乱掉的,能不 能 取呀???
      

  3.   

    <SCRIPT language=javascript>
    function index_image_valid(){
    var img=new Image();
    img.src=document.pho_up.pho_index.value;
    imagewidth=img.width;
    imageheigth=img.height;
    fsize=img.fileSize/1024;
    fsize=fsize.toFixed(1);
    document.pho_up.cmd.disabled=true;
    if(img.readyState!="complete")
      window.setTimeout("index_image_valid()",10);
    else
      {alert ("宽:"+imagewidth+"\n高:"+imageheigth+"\n大小:"+fsize+" KB");
       document.pho_up.cmd.disabled=false}
    }
    </script>
    </head>
    <form name="pho_up" method="post" enctype="multipart/form-data">
    <input type="file" name="pho_index" size="20">
    <input type=button name="cmd" value="测试图片大小" onclick="index_image_valid();"> 
    </form>