一般图片需要提交的时候,才可以获取图片的信息去判断操作的。在客户端,我以为,这个图片还不属于此document的某个对象,应该获取不到任何信息的。(除了其文件路径)这仅仅是我个人认为,如果有高手认为可以的,虚心学习中。

解决方案 »

  1.   

    用一个<img>作为过渡, 可以得到图片类型的文件宽高, 可以传递到后台:
    <input onchange="with(document.images['meizz']){src = value; style.display=''}" type=file>
    <img onload="alert(clientWidth +'\n'+ clientHeight); style.display='none'"
     border=0 id=meizz style="display: none">
      

  2.   

    Imports System.Drawing.Imaging Dim myimage As System.Drawing.Image
            Dim mywidth As Int16
            Dim myheight As Int16
    myimage = System.Drawing.Image.FromFile(filename)
                mywidth = myimage.Width
                myheight = myimage.Height
    response.write "<img src="&filename & " width=" & mywidth & " height=" & height & "/>"
          myimage.Dispose()
      

  3.   

    do as follow:<BODY>
    <SCRIPT LANGUAGE="JavaScript">
    function loadPic(pic)
    {
    if (!pic)
    return false; var oImg = new Image;
    oImg.src = pic; var MAX_HEIGHT = 300;
    var MAX_WIDTH = 400; if (pic.toUpperCase().indexOf('GIF') == -1)
    {
    alert("Not GIF format");
    divname.innerHTML = '';
    return false;
    } if (oImg.width > MAX_HEIGHT || oImg.height > MAX_WIDTH)
    {
    alert("Width(" + oImg.width + ") or Height(" + oImg.height + ") of Pic\n  get OVER the limit(" + MAX_WIDTH + '/' + MAX_HEIGHT);
    divname.innerHTML = '';
    return false;
    } divname.insertAdjacentHTML('afterBegin', "<img border=0 src='" + pic + "' width='" + oImg.width + "' height='"+oImg.height+"' border=0 onerror='alert(&quot;" + pic + " couldn't be loaded&quot;);this.style.display=&quot;none&quot;'>");}
    </SCRIPT>
    Picture Requirement:<BR>
    1.Format must be "GIF" <BR>
    2.Height not run over 400, Width not 300<BR><input onchange="loadPic(this.value)" type=file>
    <div id="divname"></div>
    </BODY>