asp.net - how to break file upload operation if file extension does not matching with my criteria? -
i have written 1 jquery code of upload files web handler. works fine want check if file's extension not matching criteria not allow upload file..
here code
$(document).ready(function () { var button = $('#fuattachment'), interval; $.ajax_upload(button, { action: 'fileuploader.ashx', name: 'myfile', onsubmit: function (file, ext) { if (ext == "js") { alert(ext); } // this.disable(); }, oncomplete: function (file, response) { window.clearinterval(interval); $('<li></li>').appendto('.files').text(file); } }); });
i getting extension in ext
variable. can check still if file contain extension want break upload operation.
how can this?? please me if knows..
you return false
onsubmit
function prevent file upload if condition not satisfied:
onsubmit: function (file, ext) { if (ext == "js") { // extension of selected file .js => allow upload return true; } // extension not .js => don't upload return false; }
Comments
Post a Comment