file upload using JQuery plug-in. Ajax file upload plug-in allows us to upload files to server.
<script type="text/javascript">
$(function() {
//Function to upload file.
new AjaxUpload('#uploadFile', {
action: 'FileUploadHandler.upload',
name: 'upload',
onComplete: function(file) {
$('<div><img src="../../Content/delete.jpg" style="width:20px;height:20px" class="delete"/>' + file + '</div>').appendTo('#fileList');
$('#uploadStatus').html("Upload Done.");
},
onSubmit: function(file, ext) {
if (!(ext && /^(txt|doc|docx|xls|pdf)$/i.test(ext))) {
alert('Invalid File Format.');
return false;
}
$('#uploadStatus').html("Uploading...");
}
});
//Function to delete uploaded file in server.
$('img').live("click", function() { $('#uploadStatus').html("Deleting"); ; deleteFile($(this)); });
});
function deleteFile(objfile) {
$.ajax({ url: 'FileUploadHandler.upload?del=' + objfile.parent().text(), success: function() { objfile.parent().hide(); } });
$('#uploadStatus').html("Deleted");
}
</script>
follow this also-
http://www.c-sharpcorner.com/UploadFile/satisharveti/745/