登录www.lebo.cn,注册一个用户,登录上传图片,看看源码。OK!

解决方案 »

  1.   

    1.赋值呢.是不允许..//用WSH也会有安全性提示的.2.
    把文件上传域清空?
    <script>   
    function  cls(){ 
    myfile.select(); 
    document.execCommand("delete"); 

    </script>   <input  type=file  name=myfile>   
    <input  type=button  onclick="cls()"  value=清除>    
      

  2.   

    wanghr100(灰豆宝宝.net)
    不行啊!你简直把我当盖茨了!yonghengdizhen(祖国啊,我为你流泪!!) 
    你有几个帐号?我急死了,弄了几天没点头绪啊,,,唉,郁闷
      

  3.   

    如果格式不对,不让提交<script language="javascript"> 
    function JudgeKeyword(aForm) 

    if (aForm.pic1name.value == "") 

    alert("请选择本地图片文件!"); 
    aForm.pic1name.focus(); 
    return false; 

    if(!(((aForm.pic1name.value.toLowerCase()).indexOf(".gif") > 0) || ((aForm.pic1name.value.toLowerCase()).indexOf(".jpg") > 0 ) || ((aForm.pic1name.value.toLowerCase()).indexOf(".jpeg") > 0 ) || 
    ((aForm.pic1name.value.toLowerCase()).indexOf(".bmp") > 0 )))

    alert("格式不对")
    return false;


    </script> 
    <form name=aForm> 
    <input type=file name=pic1name> 
    <input type=submit value="Check" onclick="return(JudgeKeyword(aForm))">
    </form>
      

  4.   

    把文件上传域清空
    <script>   
    function  cls(){ 
    myfile.select(); 
    document.execCommand("delete"); 

    </script>   <input  type=file  name=myfile>   
    <input  type=button  onclick="cls()"  value=清除>    //这个是可以的.
    //我在我的机子上测试通过了.
    //如果不行的话,我也不会贴上去的.
      

  5.   

    wanghr100(灰豆宝宝.net)你那样做很容易骗的啊,改一下扩展名你就傻了!我现在的问题是不是不能判断,而是判断后接收的页面也要知道它是不是一个图片
    谢谢!
      

  6.   

    chocolateboy(小艺) 
    K,那天给你改的时候太急,其实稍微动一下就符合要求.<HTML>
    <HEAD>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>现场照片</title>
    <script language="javascript">
    function CheckData()
    {
    nLimFileSize=800000;
    nLimWidth=600;
    nLimHeight=800;
    for(i=0;i<document.getElementsByName("Name").length;i++)
    {
    oName=document.getElementsByName("Name")[i];
    oFile=document.getElementsByName("FilePath")[i];
    nFileSize=frames["_hideFrame"].document.all.VerifyTable.rows[i].all.tags("img")[0].fileSize;
    nWidth=frames["_hideFrame"].document.all.VerifyTable.rows[i].all.tags("img")[0].width;
    nHeight=frames["_hideFrame"].document.all.VerifyTable.rows[i].all.tags("img")[0].height;
    if(oName.value=="")
    {
    oName.focus();
    alert("名称不能为空!");
    return false;
    }
    if(nFileSize==-1)
    {
    oFile.focus();
    alert("图片为空或类型无效!");
    return false;
    }
    if(nFileSize>nLimFileSize)
    {
    oFile.focus();
    alert("图片文件太大,请限制在" + nLimFileSize + "字节以内!");
    return false;
    }
    if(nWidth>nLimWidth||nHeight>nLimHeight)
    {
    oFile.focus();
    alert("图片太大,请限制在" + nLimWidth + "X" + nLimHeight + "大小!");
    return false;
    }
    }
    document.all.img.innerHTML="<div style='position:absolute;border:4px groove pink'><font size=2 color=red>开始保存图片,请耐心等待....</font></div>"
    }
    function AddMoreRow()
    {
    oRow=event.srcElement.parentNode.parentNode;
    oTable=event.srcElement.parentNode.parentNode.parentNode.parentNode;
    oNewRow=oTable.insertRow();
    for(i=0;i<oRow.cells.length;i++)
    {
    oNewRow.insertCell().innerHTML=oRow.cells[i].innerHTML;
    }
    oRow.all("DelBtn").disabled=false;
    oNewRow.all("DelBtn").disabled=false;
    oNewRow.className="content";
    frames["_hideFrame"]._AddMoreRow();
    }
    function DeleteThisRow()
    {
    oRow=event.srcElement.parentNode.parentNode;
    oTable=event.srcElement.parentNode.parentNode.parentNode.parentNode;
    if(oTable.rows.length>1)
    {
    frames["_hideFrame"]._DeleteThisRow(oRow.rowIndex);
    oTable.deleteRow(oRow.rowIndex);
    if(oTable.rows.length==1)
    {
    oTable.all("DelBtn").disabled=true;
    }
    }
    }
    function DisabledKeyInput()
    {
    if(event.keyCode!=8&&event.keyCode!=46) event.returnValue=false;
    }
    function HidePreviewPicture()
    {
    document.all.img.innerHTML="";
    }
    function VerifyPicture()
    {
    nLimFileSize=800000;
    nLimWidth=600;
    nLimHeight=800;
    oRow=event.srcElement.parentNode.parentNode;
    oImg=frames["_hideFrame"].document.all.VerifyTable.rows[oRow.rowIndex].all.tags("img")[0];
    oImg.src=event.srcElement.value;
    document.all.img.innerHTML="<img src='" + event.srcElement.value + "'>"
    document.all.img.childNodes[0].attachEvent("onerror",HidePreviewPicture)
    if(oImg.readyState=="complete")
    {
    if(oImg.fileSize==-1)
    {
    alert("文件类型无效!")
    }
    else if(oImg.fileSize>nLimFileSize)
    {
    alert("图片文件太大,请限制在" + nLimFileSize + "字节以内!")
    }
    else if(oImg.width>nLimWidth||oImg.height>nLimHeight)
    {
    alert("图片太大,请限制在" + nLimWidth + "X" + nLimHeight + "大小!")
    }
    }
    }
    </script>
    </HEAD>
    <body class=scrollbar1 topmargin=10>
    <form target="_hideFrame" method=post enctype="multipart/form-data" action="BatchAddPicture_DB.asp" onsubmit="return CheckData()">
    <table><th>批量上传</th></table>
    <table>
    <tr class=content>
    <td nowrap>名称*</td>
    <td><input type="text" name="Name" size=15 maxlength="50"></td>
    <td nowrap>文件路径*</td>
    <td>
    <input type=file name="FilePath" size=15 onkeydown="DisabledKeyInput()" onpropertychange="VerifyPicture()">
    </td>
    <td nowrap>说明</td><td><input type=text name=Description size=45><input type="button" class="input1" value="增加" onclick="AddMoreRow()"></td>
    <td nowrap>&nbsp;<input type="button" class="input1" id=DelBtn value="删除" disabled onclick="DeleteThisRow()"></td>
    </tr>
    </table>
    <table>
    <tr align =center>
    <td class="tijiao" align =center>
    &nbsp;<input type="submit" class="input1" value="保存" id=submit1 name=submit1>&nbsp;&nbsp;<input type="reset" class="input1" value="取消" id=reset1 name=reset1>
    </td>
    </tr>
    </table>
    <iframe src="about:blank" width=100% height=0 name="_hideFrame"></iframe>
    <div id="img"></div>
    <div id=tempHTML style="display:none">
    <script>
    function _AddMoreRow()
    {
    oCell=document.all.VerifyTable.insertRow().insertCell();
    oImg=document.createElement("img");
    oImg.attachEvent("onreadystatechange",_VerifyPicture);
    oImg.attachEvent("onerror",_PictureError);
    oCell.appendChild(oImg);
    }
    function _DeleteThisRow(rowIndex)
    {
    document.all.VerifyTable.deleteRow(rowIndex);
    }
    function _PictureError()
    {
    if(event.srcElement.fileSize==-1)
    {
    alert("无效的图片类型!");
    }
    }
    function _VerifyPicture()
    {
    oImg=event.srcElement;
    if(oImg.readyState=="complete")
    {
    nLimFileSize=800000;
    nLimWidth=600;
    nLimHeight=800;
    if(oImg.width>nWidth||oImg.height>nHeight)
    {
    alert("图片尺寸太大,请限制在" + nWidth + "X" + nHeight + "大小!")
    }
    else if(oImg.fileSize>nFileSize)
    {
    alert("图片文件超出限定大小,请限定在" + nHeight + "字节以内!")
    }
    }
    }
    </script>
    <table border=0 id=VerifyTable>
    <tr><td><img border=0 onerror="_PictureError()" onreadystatechange="_VerifyPicture()"></td></tr>
    </table>
    </div>
    <script language=javascript>
    function InitFrame()
    {
    frames["_hideFrame"].document.write(document.all.tempHTML.innerHTML);
    }
    window.onload=InitFrame;
    </script>
    </form>
    </BODY>
    </HTML>
      

  7.   

    至于服务端判断是否图片的代码在我的FileUpload.asp文件中已经处理了,对于文件类型的数据域,你除了可以用UploadRequest("FilePath")(i)("Value")引用图片的2进制数据之外,还可以通过UploadRequest("FilePath")(i)("ContentType")引用它的Mime类型,你判断常用的Mime类型image/jpeg image/gif等等就可以了,这些在注册表中可以找得到的..本来要将那个FileUpload.asp写成组件的,一直没有时间,等珠海回来了再慢慢折腾它去.如果你有什么疑问的话,也等我珠海回来了再慢慢和你讨论.
      

  8.   

    昏..代码居然有个地方出错了..
    改了一下,MD,珠海那帮人用了这么久居然没发现这个问题,奇怪ing,难道我手头的这份代码不是最后版本吗<HTML>
    <HEAD>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>现场照片</title>
    <script language="javascript">
    function CheckData()
    {
    nLimFileSize=800000;
    nLimWidth=600;
    nLimHeight=800;
    for(i=0;i<document.getElementsByName("Name").length;i++)
    {
    oName=document.getElementsByName("Name")[i];
    oFile=document.getElementsByName("FilePath")[i];
    nFileSize=frames["_hideFrame"].document.all.VerifyTable.rows[i].all.tags("img")[0].fileSize;
    nWidth=frames["_hideFrame"].document.all.VerifyTable.rows[i].all.tags("img")[0].width;
    nHeight=frames["_hideFrame"].document.all.VerifyTable.rows[i].all.tags("img")[0].height;
    if(oName.value=="")
    {
    oName.focus();
    alert("名称不能为空!");
    return false;
    }
    if(nFileSize==-1)
    {
    oFile.focus();
    alert("图片为空或类型无效!");
    return false;
    }
    if(nFileSize>nLimFileSize)
    {
    oFile.focus();
    alert("图片文件太大,请限制在" + nLimFileSize + "字节以内!");
    return false;
    }
    if(nWidth>nLimWidth||nHeight>nLimHeight)
    {
    oFile.focus();
    alert("图片太大,请限制在" + nLimWidth + "X" + nLimHeight + "大小!");
    return false;
    }
    }
    document.all.img.innerHTML="<div style='position:absolute;border:4px groove pink'><font size=2 color=red>开始保存图片,请耐心等待....</font></div>"
    }
    function AddMoreRow()
    {
    oRow=event.srcElement.parentNode.parentNode;
    oTable=event.srcElement.parentNode.parentNode.parentNode.parentNode;
    oNewRow=oTable.insertRow();
    for(i=0;i<oRow.cells.length;i++)
    {
    oNewRow.insertCell().innerHTML=oRow.cells[i].innerHTML;
    }
    oRow.all("DelBtn").disabled=false;
    oNewRow.all("DelBtn").disabled=false;
    oNewRow.className="content";
    frames["_hideFrame"]._AddMoreRow();
    }
    function DeleteThisRow()
    {
    oRow=event.srcElement.parentNode.parentNode;
    oTable=event.srcElement.parentNode.parentNode.parentNode.parentNode;
    if(oTable.rows.length>1)
    {
    frames["_hideFrame"]._DeleteThisRow(oRow.rowIndex);
    oTable.deleteRow(oRow.rowIndex);
    if(oTable.rows.length==1)
    {
    oTable.all("DelBtn").disabled=true;
    }
    }
    }
    function DisabledKeyInput()
    {
    if(event.keyCode!=8&&event.keyCode!=46) event.returnValue=false;
    }
    function HidePreviewPicture()
    {
    document.all.img.innerHTML="";
    }
    function VerifyPicture()
    {
    nLimFileSize=800000;
    nLimWidth=600;
    nLimHeight=800;
    oRow=event.srcElement.parentNode.parentNode;
    oImg=frames["_hideFrame"].document.all.VerifyTable.rows[oRow.rowIndex].all.tags("img")[0];
    oImg.src=event.srcElement.value;
    document.all.img.innerHTML="<img src='" + event.srcElement.value + "'>"
    document.all.img.childNodes[0].attachEvent("onerror",HidePreviewPicture)
    if(oImg.readyState=="complete")
    {
    if(oImg.fileSize==-1)
    {
    alert("文件类型无效!")
    }
    else if(oImg.fileSize>nLimFileSize)
    {
    alert("图片文件太大,请限制在" + nLimFileSize + "字节以内!")
    }
    else if(oImg.width>nLimWidth||oImg.height>nLimHeight)
    {
    alert("图片太大,请限制在" + nLimWidth + "X" + nLimHeight + "大小!")
    }
    }
    }
    </script>
    </HEAD>
    <body class=scrollbar1 topmargin=10>
    <form target="_hideFrame" method=post enctype="multipart/form-data" action="BatchAddPicture_DB.asp" onsubmit="return CheckData()">
    <table><th>批量上传</th></table>
    <table>
    <tr class=content>
    <td nowrap>名称*</td>
    <td><input type="text" name="Name" size=15 maxlength="50"></td>
    <td nowrap>文件路径*</td>
    <td>
    <input type=file name="FilePath" size=15 onkeydown="DisabledKeyInput()" onpropertychange="VerifyPicture()">
    </td>
    <td nowrap>说明</td><td><input type=text name=Description size=45><input type="button" class="input1" value="增加" onclick="AddMoreRow()"></td>
    <td nowrap>&nbsp;<input type="button" class="input1" id=DelBtn value="删除" disabled onclick="DeleteThisRow()"></td>
    </tr>
    </table>
    <table>
    <tr align =center>
    <td class="tijiao" align =center>
    &nbsp;<input type="submit" class="input1" value="保存" id=submit1 name=submit1>&nbsp;&nbsp;<input type="reset" class="input1" value="取消" id=reset1 name=reset1>
    </td>
    </tr>
    </table>
    <iframe src="about:blank" width=100% height=0 name="_hideFrame"></iframe>
    <div id="img"></div>
    <div id=tempHTML style="display:none">
    <script>
    function _AddMoreRow()
    {
    oCell=document.all.VerifyTable.insertRow().insertCell();
    oImg=document.createElement("img");
    oImg.attachEvent("onreadystatechange",_VerifyPicture);
    oImg.attachEvent("onerror",_PictureError);
    oCell.appendChild(oImg);
    }
    function _DeleteThisRow(rowIndex)
    {
    document.all.VerifyTable.deleteRow(rowIndex);
    }
    function _PictureError()
    {
    if(event.srcElement.fileSize==-1)
    {
    alert("无效的图片类型!");
    }
    }
    function _VerifyPicture()
    {
    oImg=event.srcElement;
    if(oImg.readyState=="complete")
    {
    nLimFileSize=800000;
    nLimWidth=600;
    nLimHeight=800;
    if(oImg.width>nLimWidth||oImg.height>nLimHeight)
    {
    alert("图片尺寸太大,请限制在" + nLimWidth + "X" + nLimHeight + "大小!")
    }
    else if(oImg.fileSize>nFileSize)
    {
    alert("图片文件超出限定大小,请限定在" + nLimFileSize+ "字节以内!")
    }
    }
    }
    </script>
    <table border=0 id=VerifyTable>
    <tr><td><img border=0 onerror="_PictureError()" onreadystatechange="_VerifyPicture()"></td></tr>
    </table>
    </div>
    <script language=javascript>
    function InitFrame()
    {
    frames["_hideFrame"].document.write(document.all.tempHTML.innerHTML);
    }
    window.onload=InitFrame;
    </script>
    </form>
    </BODY>
    </HTML>
      

  9.   

    wanghr100(灰豆宝宝.net)
    你的方法在我的机器上根本行不通,不知道有什么根据
    win2000+IE6.0