Possible Duplicate:
File Upload ASP.NET MVC 3.0
I am trying to just print out the name of the file in the debugger to make sure I am getting it this far:
<EmployeeAuthorize()> <HttpPost()> Function SendNewMessage(ByVal file1 As HttpPostedFileBase) As JsonResult Dim fileName = Path.GetFileName(file1.FileName) Debug.Print(fileName) Return Nothing End Function I am sending the data with this:
var file1 = $('#file1').val(); $(this).parent('li').hide(); $('#pleaseWait').show(); $.ajax({ url: '/Message/SendNewMessage', type: 'post', data: { file1: file1 }, dataType: 'json', success: function (result) { // update with results //alert(JSON.stringify(result)); $.each(result, function (i, item) { // do nothing }); $('#myDiv').html(JSON.stringify(result)); }, error: function (result) { alert('An error occurred when updating the database. Please contact technical support. '); } }); It doesn't print any data in my console. It gives a NullReferenceException so I can assume it's not getting the filename at all. What am I doing wrong? Thanks.