Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

How do I cancel an AsyncFileUpload when a file has been selected because wrong file extension was selected

$
0
0

Only file with these extension(.jpg, .png, .gif) is allowed how can I cancel an ongoing AsyncFileUpload so that the client function OnClientUploadComplete is not called
Even if I check in this event handler method AsyncFileUpload1_OnUploadedComplete and do return if wrong
file extension has been selected the client function OnClientUploadComplete is still called

protected void AsyncFileUpload1_OnUploadedComplete(object sender, AsyncFileUploadEventArgs e)
     {
         string id = Request.QueryString["ID"];

         //Here I went to check rhat a file with correct extension has been selected
         //if (Path.GetExtension(FileUploadBild.FileName).ToLower() != ".jpg" &&
         //            Path.GetExtension(FileUploadBild.FileName).ToLower() != ".png" &&
         //            Path.GetExtension(FileUploadBild.FileName).ToLower() != ".gif")

         //Copy file to temp folder
         AsyncFileUpload1.PostedFile.SaveAs(path + e.FileName);
         path += e.FileName;

         //Upload image to ftp server
         FileManager.HandleUpload(path, id);

         //Update database
         backEnd.InsertIntoPictures(id, AsyncFileUpload1.FileName);
     }

//Tony


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>