Java脚本文件控制 [英] java script file control

查看:67
本文介绍了Java脚本文件控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一个文件上传站点,在该站点中,如果用户两次选择相同的文件,那么我想通过javascript清除该值,
如何将html文件控件的路径更改为null.

谢谢&问候

i am building a file uploading site ,in which if user select same file twice then i want to clear that value by javascript,
how can i change html file control''s path to null.

thanks & Regards

推荐答案

您可以使用以下命令清除上传文件的值:

You can clear upload file value using following:

document.getElementById('<%=fluUpload.ClientID%>').value='';


调用以ConrolID作为参数的javascript函数
call floowing javascript function with ConrolID as parameter
<script type="text/javascript"> 
function clearFileInput( id )
{
   var elem = document.getElementById( id );
   elem.parentNode.innerHTML = "";
}
</script>




我尝试了一些符合您要求的代码.试试这个
Hi,

I tried some code for your requirement.Try this
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script language ="javascript" >
        function f1() {
            document.getElementById("fileupload1").parentElement.innerHTML = "<input type =\"file\" id=\"fileupload1\"  />";
      }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <div id="divid" runat="server">
    <input type ="file" id="fileupload1"  />
    </div>
     
     <input type ="button" value="change" onclick ="f1()" />
        <asp:button id="Button1" runat="server" text="Button" onclientclick="f1()" onclick="Button1_Click" xmlns:asp="#unknown" />
   

    </div>
    </form>
</body>
</html>



希望它也能为您服务.

我搜索了很多,但找不到正确的解决方案,因为.

如果我们更改文件类型输入标签,则会导致某些安全漏洞.

终于我尝试了这段代码.希望您能理解我说的话

如果使用Jquery,则可以在服务器端检查用户上传的文件.

最好的



I hope It can works for you also.

I searched alot but i don''t find correct solution because.

If we change file type input tags it leads to some security breaches .

finally I tried this code .I hope you understood what I said

If you use Jquery Then you can check user uploaded files in server side.

All the Best


这篇关于Java脚本文件控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆