重複の可能性:
ファイルのアップロードASP.NET MVC 3.0
デバッガーでファイルの名前を出力して、ここまで取得していることを確認しようとしています。
<EmployeeAuthorize()>
<HttpPost()>
Function SendNewMessage(ByVal file1 As HttpPostedFileBase) As JsonResult
Dim fileName = Path.GetFileName(file1.FileName)
Debug.Print(fileName)
Return Nothing
End Function
私はこれでデータを送信しています:
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. ');
}
});
コンソールにデータが出力されません。NullReferenceException
ファイル名がまったく取得されていないと推測できるようになります。私は何が間違っているのですか?ありがとう。