c# - How to show a error message when wrong file uploaded other than(jpeg) in ajax_uploadfile asp.net using jquery? -
i working on asp.net ajax_uploadfile here need show error message had given allowedfiletypes="jpg,jpeg,png"
here code:
<asp:ajaxfileupload runat="server" throbberid="throbber" id="upfile" allowedfiletypes="pdf" onchange="callingerrormesage()" maximumnumberoffiles="5" onclientuploadcomplete="file_upload" />
here script code:
<scrpt> function callingerrormesage(){ alert(1); } </script>
here code behind:
protected void file_upload(object sender, ajaxfileuploadeventargs e) { string filename = e.filename; string strdestpath = server.mappath("~/documents/"); ajaxfileupload1.saveas(@strdestpath + filename); }
when uploaded jpeg
file it's working fine when need upload other jpeg file need show error message
i had given onchange="callingerrormesage()"
not working please me on this?
you should validate before uploading this:
$("input:file").change(function () { if ($(this).val() !== "") { var ul_file = $(this).val(); var extension = ul_file.substr((ul_file.lastindexof('.') + 1)); var accepted_file_endings = ["jpg", "jpeg"]; extension = extension.tolowercase() if ($.inarray(extension, accepted_file_endings) !== -1) { ... //send file
Comments
Post a Comment