Upload File Jquery AJAX

Create input text with id yearcashreport and and input file with id afsuserfile & button with id uploadafs (HTML)

Javascript

$('#uploadafs').on('click', function(){
			var afsdata = false;
			if (window.FormData) {
				afsdata = new FormData();
			}

			if (afsdata) {
				afsdata.append('userfile', $("#afsuserfile").prop("files")[0]);
				afsdata.append('yearcashreport', $('#yearcashreport').val());
			}

			if (afsdata) {
				$.ajax({
					url: '',
					type: "POST",
					data: afsdata,
					processData: false,
					contentType: false,
					success:function(data){
						$('.msgupload').html(data);
					}
				})
			}
		});