如何在异步FileUpload中查找重复文件 [英] how to find duplicate file in async FileUpload

查看:77
本文介绍了如何在异步FileUpload中查找重复文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ajax async Fileupload上传文件,但是当我添加已存在的文件名已存在的文件时,文件上传替换旧文件是否有任何方法可以查找文件名是否已存在

我当前的代码是

i am using ajax async Fileupload to upload a file but when i am adding a file which already exist for name of the file already exist then file upload replace the old file is there any method to find if file name already exist
my current code is

<div>
                  <cc1:AsyncFileUpload ID="txtTenderDoc" OnClientUploadComplete="uploadComplete" OnClientUploadError="uploadError"
                      ErrorBackColor="Red" MaxFiles="10" CompleteBackColor="Lime" Width="280px"  runat="server"
                      UploaderStyle="Modern" UploadingBackColor="#CCFFFF" ThrobberID="imgLoad"  önUploadedComplete="fileUploadComplete"
                      ClientIDMode="AutoID" />
                  <br />
                  <asp:Image ID="imgLoad" runat="server" ImageUrl="~/Styles/img/loading.gif" />
                  <br />
                  <asp:Label ID="lblMsg" runat="server" Text=""></asp:Label>
              </div>

protected void fileUploadComplete(object sender, AsyncFileUploadEventArgs e)
  {
      Thread.Sleep(20000);
      string filename = System.IO.Path.GetFileName(txtTenderDoc.FileName);
      txtTenderDoc.SaveAs(Server.MapPath("~/Document/") + filename);
  }




function uploadComplete() {
    document.getElementById('<%=lblMsg.ClientID %>').innerHTML = "File Uploaded Successfully";
}

function uploadError() {
    document.getElementById('<%=lblMsg.ClientID %>').innerHTML = "File upload Failed.";
}

推荐答案

参见 这个 (如果重新访问页面,如何清除AsyncFileUpload) [ ^ ]

线程,它可能会有帮助。



干杯,

Edo
See this (How to clear AsyncFileUpload if page revisited) [^]
thread, it might help.

Cheers,
Edo


这篇关于如何在异步FileUpload中查找重复文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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