How can I check if the file selected in AjaxFileUpload has already been uploaded or is pending?
For example:
https://i.stack.imgur.com/q6qUQ.png
I want to validate files that are still pending upload. Here is my .aspx page code
<form id="form1" runat="server">
<asp:ToolkitScriptManager runat="server">
</asp:ToolkitScriptManager>
<asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server"
Width="400px" OnUploadComplete="OnUploadComplete" Mode="Auto" />
</form>
.aspx.cs code is
protected void OnUploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
{
string fileName = Path.GetFileName(e.FileName);
AjaxFileUpload1.SaveAs(Server.MapPath("~/uploads/" + fileName));
}
If I have already uploaded 2 files and then add a new file for upload, how do I verify that the 2 files are uploaded but not the new one. This validation needs to be done using JavaScript
This validation should be triggered by any button's onclientclick event.
Resolved using the following javascript
function validateImageUploaded() {
if ($(".ajax__fileupload_fileItemInfo").length > 0) {
if ($("div.ajax__fileupload_fileItemInfo").children('div').hasClass("pendingState"))
{
alert("found");
return false;
}
}
else {
alert('select your file');
return false;
}}