document.uploadForm.myphoto.src="img_2_1.gif";
替换为:
document.images["myphoto"].src="img_2_1.gif";

解决方案 »

  1.   

    function  ErrImgBig(){
    if  (img.fileSize>maxfilesize)
             {
                uploadForm.reset();
       alert("您上传的图片大于200K!");
                document.uploadForm.myphoto.src="img_2_1.gif";
       return false;
            }
    }
    改为:function  ErrImgBig(){
    if  (img.fileSize>maxfilesize)
             {
       alert("您上传的图片大于200K!");
                document.uploadForm.myphoto.src="img_2_1.gif";
       return false;
            }
    }试试
      

  2.   

    //试试
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
    <script>
    var  img=null;
    var diskuse = 0
    var quota = 20971520
    var maxfilesize = 204800;function  checkimage(td){
    var name = document.uploadForm.fileLocation.value;
    if(/^.+\.(gif|jpg|pjpeg|bmp)$/i.test(name)){
    if(img)img.removeNode(true);
    img=document.createElement("img");
    img.style.position="absolute";
    img.style.visibility="hidden";
    img.attachEvent("onerror",ErrImgType);
    img.attachEvent("onreadystatechange",ErrImgBig);
    document.body.insertAdjacentElement("beforeend",img);
    img.src=name;
                    document.uploadForm.myphoto.src=td.value;
    }
    else{ErrImgType()}
    }function  ErrImgType(){
    //uploadForm.reset();

    alert("上传图片文件类型只能是jpg,gif,pjpeg或bmp格式!");
         document.getElementById("myphoto").src="img_2_1.gif";    
    return false;
    }
    function reimg()
    {
    document.getElementById("myphoto").src="img_2_1.gif";
    }
    function  ErrImgBig(){
    if  (img.fileSize>maxfilesize)
             {
             
            uploadForm.reset();
            setTimeout('reimg()',200);
             alert("您上传的图片大于200K!");
            
      
           // 
            
       return false;
            }
    }
    </script>
    <form action='test.asp' name="uploadForm" ID=Form1>
    <table><tr>
    <td width="208" valign="top"><img name='myphoto' id="myphoto" src="img_2_1.gif" width="237" height="255" ></td
    </tr>
    <tr>
    <td height="19" class="style4" size = 60>&nbsp;&nbsp;&nbsp;&nbsp;<INPUT mtyle="FONT-SIZE: 9pt" type="File" name="fileLocation" size=60 onChange="checkimage(this);" ID=File1></td>
    </tr>
    </table>
    </form>
    </body>
    </html>