文件上传...浏览点不了?是怎么回事?


比如,有一个页面,上面有4的FileUpLoad控件,对应着4个Button,如果上传一点文件成功后,所有的FileUpLoad控件的浏览都不能点了,Button却可以点,要刷新页面、或重新打开页面后FileUpLoad的浏览才可以用?这是什么原因啊?求解决

8 个解决方案

#1


应该不会吧,把你的代码发出来看看

#2


IE下运行,这种情况很少出现,但是也出现过,只是很少出现,
搜狗不能用

#3



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FileUpLoad.aspx.cs" Inherits="Admin_FileUpLoad_FileUpLoad" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <script src="../css/DatePicker/WdatePicker.js" type="text/javascript"></script>
    
    <title>添加法律法规</title>
    <link href="../images/admin.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript">
       
        
    </script>
    <style type="text/css">
        .style1
        {
            width: 75%;
        }
    </style>
</head>
<body>

<form id="Form2" name="form1" runat="server">
<table border="0" align="center" cellpadding="3" cellspacing="1" 
        
        style="background-color:#ECECFF; width: 98%;  height:63px; border:1px solid #E0E0E0">
  <tr>
    <td>
        位置:客户管理 -&gt;客户列表 &nbsp; &nbsp; &nbsp;</td>
  </tr>
  <tr >
    <td style="border:0px; margin-bottom:10px;" >
         <img src="../images/menu_bgs.gif" style="width:100%; height: 28px;border:1px solid #E0E0E0;" alt="" />
    </td>
    </tr>
</table>
  <table width="38%" border="0" align="center" cellpadding="3" cellspacing="1" 

class="tableborder">
    <tr class="header"> 
      <td height="25" colspan="2">
          表格信息&nbsp;
        </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td width="25%" height="25">
          工商融资表格</td>
      <td height="25" class="style1">
          <asp:FileUpload ID="FileUpload1" runat="server" />
&nbsp;
          <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="上传" />
         </td>
    
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">
          地方城投表格</td>
      <td height="25" class="style1">
          <asp:FileUpload ID="FileUpload2" runat="server" />
&nbsp;
          <asp:Button ID="Button2" runat="server" Text="上传" onclick="Button2_Click" />
         </td>
    </tr>
      <tr bgcolor="#FFFFFF"> 
      <td width="25%" height="25">
          个人经营表格</td>
      <td height="25" class="style1">
          <asp:FileUpload ID="FileUpload3" runat="server" />
&nbsp;
          <asp:Button ID="Button3" runat="server" Text="上传" onclick="Button3_Click" />
          </td>
          </tr>
       <tr bgcolor="#FFFFFF"> 
      <td width="25%" height="25">
          推荐项目表格</td>
      <td height="25" class="style1">
          <asp:FileUpload ID="FileUpload4" runat="server" />
&nbsp;
          <asp:Button ID="Button4" runat="server" Text="上传" onclick="Button4_Click" />
          </td>
    </tr>
          <tr bgcolor="#FFFFFF"> 
      <td width="25%" height="25">
          常年顾问表格</td>
      <td height="25" class="style1">
          <asp:FileUpload ID="FileUpload5" runat="server" />
&nbsp;
          <asp:Button ID="Button5" runat="server" Text="上传" onclick="Button5_Click" />
          </td>
    </tr>
    
  </table>
  </form>
</body>
</html>




 using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using YKW.YKWModel;
using System.Configuration;

public partial class Admin_FileUpLoad_FileUpLoad : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack) { 
         
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (FileUpload1.FileName != "")
        {
            DelFile("1");
            string Name = FileUpload1.FileName;
            string exe = Path.GetExtension(Name);
            string NewName = 1 + exe;
            string url = Server.MapPath("File");
            FileUpload1.SaveAs(url + "\\" + NewName);
            Response.Write("<script>alert('上传成功');location.href='FileUpLoad.aspx?js=" + new Random().Next() + "';</script>");
        }
        else
        {
            Response.Write("<script>alert('请选择文件');location.href='FileUpLoad.aspx?js=" + new Random().Next() + "';</script>");
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        if (FileUpload2.FileName != "")
        {
            DelFile("2");
            string Name = FileUpload2.FileName;
            string exe = Path.GetExtension(Name);
            string NewName = 2 + exe;
            string url = Server.MapPath("File");
            FileUpload2.SaveAs(url + "\\" + NewName);
            Response.Write("<script>alert('上传成功');location.href='FileUpLoad.aspx?js=" + new Random().Next() + "';</script>");
        }
        else {
            Response.Write("<script>alert('请选择文件');location.href='FileUpLoad.aspx?js=" + new Random().Next() + "';</script>");
        }
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        if (FileUpload3.FileName != "")
        {
            DelFile("3");
            string Name = FileUpload3.FileName;
            string exe = Path.GetExtension(Name);
            string NewName = 3 + exe;
            string url = Server.MapPath("File");
            FileUpload3.SaveAs(url + "\\" + NewName);
            Response.Write("<script>alert('上传成功');location.href='FileUpLoad.aspx?js=" + new Random().Next() + "';</script>");
        }
        else {
            Response.Write("<script>alert('请选择文件');location.href='FileUpLoad.aspx?js=" + new Random().Next() + "';</script>");
        }
    }
    protected void Button4_Click(object sender, EventArgs e)
    {
        if (FileUpload4.FileName != "")
        {
            DelFile("4");
            string Name = FileUpload4.FileName;
            string exe = Path.GetExtension(Name);
            string NewName = 4 + exe;
            string url = Server.MapPath("File");
            FileUpload4.SaveAs(url + "\\" + NewName);
            Response.Write("<script>alert('上传成功');location.href='FileUpLoad.aspx?js=" + new Random().Next() + "';</script>");
        }
        else
        {
            Response.Write("<script>alert('请选择文件');location.href='FileUpLoad.aspx?js=" + new Random().Next() + "';</script>");
          
        }
    }
    protected void Button5_Click(object sender, EventArgs e)
    {
        if (FileUpload5.FileName != "")
        {
            DelFile("5");
            string Name = FileUpload5.FileName;
            string exe = Path.GetExtension(Name);
            string NewName = 5 + exe;
            string url = Server.MapPath("File");
            FileUpload5.SaveAs(url + "\\" + NewName);
            Response.Write("<script>alert('上传成功');location.href='FileUpLoad.aspx?js=" + new Random().Next() + "';</script>");
        }
        else {
            Response.Write("<script>alert('请选择文件');location.href='FileUpLoad.aspx?js=" + new Random().Next() + "';</script>");
        }
    }

    public void DelFile(string str)
    {
        string path = ConfigurationManager.AppSettings["Files"];
        string[] file1 = Directory.GetFiles(path + "Admin\\FileUpLoad\\File");
        foreach (string f in file1)
        {
            string[] s = f.Split('\\');
            string file = s[s.Length - 1].Split('.')[0];
            if (file == str)
            {
                File.Delete(f);
            }
        }
    }
}

#4


测试了一下  发现代码没问题啊   在我这里上传一个后  都还能用

#5


IE可以用,极少数情况下不能用,用搜狗完成不能用个

#6


搜狗完全不能用

#7


 this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "dd",
                    "<script>"<script>alert('上传成功');location.href='FileUpLoad.aspx?js=" + new Random().Next() + "';</script>");

所有的提示都用这种形式

#8


当你点击一个上传成功后 触发后台事件之后页面也就会刷新 你所记录的那个信息就不起作用了 
智能推荐

注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告