Click here to Skip to main content
14,926,224 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
once i select the file using asyncfileupload, the file is already uploading to the server. once finished, i click the button, then the file originally uploaded upload again to the server.

i tried whatever i could, please advice :(

<script type="text/javascript">
        //upload file
        function uploadError(sender, args) {
            document.getElementById('lblStatusFupFile').innerText = args.get_fileName(), "" + args.get_errorMessage() + "";

        function StartUpload(sender, args) {
            document.getElementById('lblStatusFupFile').innerText = 'Uploading...';

        function UploadComplete(sender, args) {
            var filename = args.get_fileName();
            var contentType = args.get_contentType();
            var text = "File name: " + filename + " is uploaded.";
            document.getElementById('lblStatusFupFile').innerText = text;

<asp:ScriptManager ID="ScriptManager1" runat="server">
       <asp:UpdatePanel ID="UpdatePanel1" runat="server">
               <asp:PostBackTrigger ControlID="btnUpload" />
           <asp:Button runat="server" Text="Upload" ValidationGroup="upload" ID="btnUpload" OnClick="btnUpload_Click"></asp:Button>
           <asp:AsyncFileUpload runat="server" OnClientUploadStarted="StartUpload" OnClientUploadComplete="UploadComplete" OnClientUploadError="uploadError" ThrobberID="ThrobberFile" UploadingBackColor="#66CCFF" Width="400px" FailedValidation="False" UploaderStyle="Modern" ID="fupFile" OnUploadedComplete="fupFile_UploadedComplete"></asp:AsyncFileUpload>
           <asp:Label ID="lblStatusFupFile" runat="server" Style="font-family: Arial; font-size: small; color: #000000;"></asp:Label>
           <asp:Label runat="server" ID="lblValAfuFile" Style="color: #FF0000; font-weight: 700"></asp:Label>

code behind:
 protected void fupFile_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
               if (fupFile.HasFile)
                   string strPath = MapPath("~/Uploads/files/") + Path.GetFileName(e.FileName);

protected void btnUpload_Click(object sender, EventArgs e)
           if (this.fupFile.FileName == "")
               this.lblValAfuFile.Text = "* File required.";
     //some code

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900