文件上传不工作在Firefox [英] file upload not working in firefox

查看:127
本文介绍了文件上传不工作在Firefox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$ p
$ b pre $ < input id =MyTextBoxrunat =servertype = textname =T1size =20/>

< asp:Button ID =UploadFileButtonrunat =serverText =Upload/>

< input id =FileUploadrunat =servertype =filestyle =height:22px; visibility:hidden; />

链接到JS脚本:

<$ p $ live(click,function(event){

event.preventDefault();

$(#UploadFileButton (#FileUpload)。click();

}); $($#
$('#FileUpload')。change(function(){
$(#MyTextBox)。val($(this).val() );
});
});

这意味着当用户点击 UploadFileButton 时,选择的文件选择弹出显示。

在用户选择文件MyTextBox = Selct文件路径。

我的问题是,我的脚本工作Chrome但不在Firefox。

如果有人已经遇到了这个问题,请任何想法。

解决方案

我有同样的问题,可以使用这段代码:

 < input id =FileUploadrunat =servertype =filestyle =height:22px; onchange =fill();/> 

< script language =javascript>
function fill()
{
$(#<%= MyTextBox.ClientID%>).val ($(#<%= FileUpload.C​​lientID%>).val())
}
< / script>


I have in my asp.net page

       <input id="MyTextBox" runat="server" type="text" name="T1" size="20"/>

       <asp:Button ID="UploadFileButton" runat="server" Text="Upload"  /> 

      <input id="FileUpload" runat="server"  type="file"  style="height: 22px; visibility:hidden;" />

linked to JS script:

       $("#UploadFileButton").live("click", function(event) {

            event.preventDefault();

            $("#FileUpload").click();

       });
     $(function() {
       $('#FileUpload').change(function() {
               $("#MyTextBox").val($(this).val());
        });
    });

This means when the user click UploadFileButton ,the chose file select popup shows.
After the user chose a file the MyTextBox=Selct file path.

My problem is that my script works in Chrome but not in Firefox.
Any ideas please if someone has already encountered this problem.

解决方案

I had the same problem, you can use this code:

<input id="FileUpload" runat="server"  type="file"  style="height: 22px; onchange="fill();"/>

    <script language="javascript">
    function fill()
    {    
      $("#<%=MyTextBox.ClientID%>").val($("#<%=FileUpload.ClientID%>").val())
    }
    </script>

这篇关于文件上传不工作在Firefox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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